Skip to content

Commit

Permalink
update release script
Browse files Browse the repository at this point in the history
  • Loading branch information
chaance committed Aug 27, 2021
1 parent b483747 commit cc61615
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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##*/}
15 changes: 4 additions & 11 deletions scripts/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const jsonfile = require("jsonfile");
const semver = require("semver");

const rootDir = path.resolve(__dirname, "..");
const version = process.argv[2];

/**
* @param {*} cond
Expand All @@ -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
Expand All @@ -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();
Expand All @@ -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."
Expand All @@ -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
Expand Down

0 comments on commit cc61615

Please sign in to comment.