From 6578bf25518e0d28c55a0afcdbade7214fca5e49 Mon Sep 17 00:00:00 2001 From: Mayank Date: Thu, 13 Jun 2024 12:55:03 +0530 Subject: [PATCH] Update publish scripts to auto update SECURITY file --- scripts/manual-publish.js | 1 + scripts/publish.js | 1 + scripts/update-security-md.js | 15 +++++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 scripts/update-security-md.js diff --git a/scripts/manual-publish.js b/scripts/manual-publish.js index d5095642..c262622d 100644 --- a/scripts/manual-publish.js +++ b/scripts/manual-publish.js @@ -50,6 +50,7 @@ const isNotPatch = newMajor !== oldMajor || newMinor !== oldMinor; const pushCmd = `git add . && git commit -m "Apply changesets and update CHANGELOG" && git push origin ${BRANCH}`; if (isNotPatch && BRANCH === DEFAULT_BRANCH) { + require("./update-security-md")(`${newMajor}.${newMinor}`, `${oldMajor}.${oldMinor}`); execSync(pushCmd); /** Create new release branch for every Major or Minor release */ const releaseBranch = `release-${newMajor}.${newMinor}`; diff --git a/scripts/publish.js b/scripts/publish.js index c461be0d..6a56ef29 100644 --- a/scripts/publish.js +++ b/scripts/publish.js @@ -33,6 +33,7 @@ const [oldMajor, oldMinor] = LATEST_VERSION.split("."); const isPatch = newMajor === oldMajor && newMinor === oldMinor; if (!isPatch) { + require("./update-security-md")(`${newMajor}.${newMinor}`, `${oldMajor}.${oldMinor}`); /** Create new release branch for every Major or Minor release */ const releaseBranch = `release-${newMajor}.${newMinor}`; execSync(`git checkout -b ${releaseBranch} && git push origin ${releaseBranch}`); diff --git a/scripts/update-security-md.js b/scripts/update-security-md.js new file mode 100644 index 00000000..67f8944a --- /dev/null +++ b/scripts/update-security-md.js @@ -0,0 +1,15 @@ +const { execSync } = require("child_process"); + +module.exports = (newMajor_minor, oldMajor_minor) => { + /** Update SECURITY.md */ + execSync( + `sed -i -e "s/.*| :white_check_mark:.*/| ${newMajor_minor}.x | :white_check_mark: |/" SECURITY.md`, + ); + execSync( + `sed -i -e "s/.*| :warning:.*/| ${oldMajor_minor}.x | :warning: |/" SECURITY.md`, + ); + execSync(`sed -i -e "s/.*| :x:.*/| < ${oldMajor_minor} | :x: |/" SECURITY.md`); + execSync( + `git add SECURITY.md && git commit -m 'Update SECURITY.md [skip ci]' && git push origin ${process.env.BRANCH}`, + ); +};