Skip to content

Commit 4511e90

Browse files
committed
chore: add a release script
1 parent 6cd284a commit 4511e90

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"lint:fix": "pnpm prettier:fix && pnpm lint:check && pnpm prettier:check",
4040
"prettier:check": "prettier -u --check '**/*.{js,ts,tsx,md}' '!**/.nx/**'",
4141
"prettier:fix": "prettier -u --write '**/*.{js,ts,tsx,md}' '!**/.nx/**'",
42-
"style": "pnpm lint:fix"
42+
"style": "pnpm lint:fix",
43+
"release": "node ./scripts/release.js"
4344
},
4445
"keywords": [
4546
"relayer",

scripts/release.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const path = require('path');
2+
const { exec, getExecOutput } = require('@actions/exec');
3+
4+
const { version } = require('../package.json');
5+
const tag = `${version}`;
6+
7+
process.chdir(path.join(__dirname, '..'));
8+
9+
(async () => {
10+
const { exitCode, stderr } = await getExecOutput(
11+
`git`,
12+
['ls-remote', '--exit-code', 'origin', '--tags', `refs/tags/${tag}`],
13+
{
14+
ignoreReturnCode: true,
15+
},
16+
);
17+
if (exitCode === 0) {
18+
console.log(`Action is not being published because version ${tag} is already published`);
19+
return;
20+
}
21+
if (exitCode !== 2) {
22+
throw new Error(`git ls-remote exited with ${exitCode}:\n${stderr}`);
23+
}
24+
25+
await exec('changeset', ['publish']);
26+
27+
await exec('changeset', ['tag']);
28+
})();

0 commit comments

Comments
 (0)