Skip to content

Commit cc61615

Browse files
committed
update release script
1 parent b483747 commit cc61615

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ jobs:
3434
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
3535
run: |
3636
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
37-
node scripts/publish.js
37+
node scripts/publish.js ${GITHUB_REF##*/}

scripts/publish.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const jsonfile = require("jsonfile");
44
const semver = require("semver");
55

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

89
/**
910
* @param {*} cond
@@ -14,14 +15,6 @@ function invariant(cond, message) {
1415
if (!cond) throw new Error(message);
1516
}
1617

17-
/**
18-
* @returns {string}
19-
*/
20-
function getTaggedVersion() {
21-
let output = execSync("git tag --list --points-at HEAD").toString();
22-
return output.replace(/^v|\n+$/g, "");
23-
}
24-
2518
/**
2619
* @param {string} packageName
2720
* @param {string|number} version
@@ -41,7 +34,7 @@ async function ensureBuildVersion(packageName, version) {
4134
*/
4235
function publishBuild(packageName, tag) {
4336
let buildDir = path.join(rootDir, "packages", packageName);
44-
let command = `npm publish ${buildDir}` + tag ? ` --tag ${tag}` : "";
37+
let command = `npm publish ${buildDir}` + (tag ? ` --tag ${tag}` : "");
4538
console.log();
4639
console.log(` ${command}`);
4740
console.log();
@@ -60,7 +53,6 @@ async function run() {
6053
);
6154

6255
// 1. Get the current tag, which has the release version number
63-
let version = getTaggedVersion();
6456
invariant(
6557
version !== "",
6658
"Missing release version. Run the version script first."
@@ -71,7 +63,8 @@ async function run() {
7163

7264
console.log();
7365
console.log(
74-
` Publishing version ${version} to npm` + tag ? ` with tag "${tag}"` : ""
66+
` Publishing version ${version} to npm` +
67+
(tag ? ` with tag "${tag}"` : "")
7568
);
7669

7770
// 3. Ensure build versions match the release version

0 commit comments

Comments
 (0)