From 1e2776dea43defdae40a9dae1be389189c8eb1ef Mon Sep 17 00:00:00 2001 From: Mayank Date: Mon, 17 Jun 2024 22:04:59 +0530 Subject: [PATCH] fix: Reenable full publish script --- scripts/publish.js | 58 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/scripts/publish.js b/scripts/publish.js index 9ec981c3..5312cb68 100644 --- a/scripts/publish.js +++ b/scripts/publish.js @@ -7,45 +7,45 @@ try { } catch { // empty } -// try { -// execSync("pnpm changeset version"); -// execSync( -// `git add . && git commit -m "Apply changesets and update CHANGELOG" && git push origin ${process.env.BRANCH}`, -// ); -// } catch { -// // no changesets to be applied -// } +try { + execSync("pnpm changeset version"); + execSync( + `git add . && git commit -m "Apply changesets and update CHANGELOG" && git push origin ${process.env.BRANCH}`, + ); +} catch { + // no changesets to be applied +} -// const { version: VERSION, name } = require("../lib/package.json"); -// let LATEST_VERSION = "0.0.-1"; +const { version: VERSION, name } = require("../lib/package.json"); +let LATEST_VERSION = "0.0.-1"; -// try { -// LATEST_VERSION = execSync(`npm view ${name} version`).toString() ?? "0.0.-1"; -// } catch { -// // empty -// } +try { + LATEST_VERSION = execSync(`npm view ${name} version`).toString() ?? "0.0.-1"; +} catch { + // empty +} -// console.log({ VERSION, LATEST_VERSION }); +console.log({ VERSION, LATEST_VERSION }); -// const [newMajor, newMinor] = VERSION.split("."); -// const [oldMajor, oldMinor] = LATEST_VERSION.split("."); +const [newMajor, newMinor] = VERSION.split("."); +const [oldMajor, oldMinor] = LATEST_VERSION.split("."); -// const isPatch = newMajor === oldMajor && newMinor === oldMinor; +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}`); -// } +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}`); +} /** Create release */ -execSync("cd lib && pnpm build"); +execSync("cd lib && pnpm build && npm publish --provenance --access public"); /** Create GitHub release */ -// execSync( -// `gh release create ${VERSION} --generate-notes --latest -n "$(sed '1,/^## /d;/^## /,$d' CHANGELOG.md)" --title "Release v${VERSION}"`, -// ); +execSync( + `gh release create ${VERSION} --generate-notes --latest -n "$(sed '1,/^## /d;/^## /,$d' CHANGELOG.md)" --title "Release v${VERSION}"`, +); // Publish canonical packages [