From cc616158f7d2def61587aa4cdbd3c8141f6cd70c Mon Sep 17 00:00:00 2001 From: Chance Strickland Date: Fri, 27 Aug 2021 15:50:48 -0700 Subject: [PATCH] update release script --- .github/workflows/release.yml | 2 +- scripts/publish.js | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5755a8f384..49f16cb039 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,4 +34,4 @@ jobs: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} run: | echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc - node scripts/publish.js + node scripts/publish.js ${GITHUB_REF##*/} diff --git a/scripts/publish.js b/scripts/publish.js index 745050021a..dbf4d985d2 100644 --- a/scripts/publish.js +++ b/scripts/publish.js @@ -4,6 +4,7 @@ const jsonfile = require("jsonfile"); const semver = require("semver"); const rootDir = path.resolve(__dirname, ".."); +const version = process.argv[2]; /** * @param {*} cond @@ -14,14 +15,6 @@ function invariant(cond, message) { if (!cond) throw new Error(message); } -/** - * @returns {string} - */ -function getTaggedVersion() { - let output = execSync("git tag --list --points-at HEAD").toString(); - return output.replace(/^v|\n+$/g, ""); -} - /** * @param {string} packageName * @param {string|number} version @@ -41,7 +34,7 @@ async function ensureBuildVersion(packageName, version) { */ function publishBuild(packageName, tag) { let buildDir = path.join(rootDir, "packages", packageName); - let command = `npm publish ${buildDir}` + tag ? ` --tag ${tag}` : ""; + let command = `npm publish ${buildDir}` + (tag ? ` --tag ${tag}` : ""); console.log(); console.log(` ${command}`); console.log(); @@ -60,7 +53,6 @@ async function run() { ); // 1. Get the current tag, which has the release version number - let version = getTaggedVersion(); invariant( version !== "", "Missing release version. Run the version script first." @@ -71,7 +63,8 @@ async function run() { console.log(); console.log( - ` Publishing version ${version} to npm` + tag ? ` with tag "${tag}"` : "" + ` Publishing version ${version} to npm` + + (tag ? ` with tag "${tag}"` : "") ); // 3. Ensure build versions match the release version