@@ -2,11 +2,6 @@ name: Release
22
33on :
44 workflow_dispatch :
5- inputs :
6- version :
7- description : " Version to release (must match package.json and jsr.json)"
8- required : true
9- type : string
105
116permissions :
127 contents : read
1712 runs-on : ubuntu-latest
1813
1914 steps :
15+ - name : Ensure release runs on main
16+ if : github.ref_name != 'main'
17+ run : |
18+ echo "Release workflow must be triggered on the main branch."
19+ exit 1
20+
2021 - name : Checkout
2122 uses : actions/checkout@v4
2223
@@ -27,29 +28,33 @@ jobs:
2728 uses : actions/setup-node@v4
2829 with :
2930 node-version : 22
30- registry-url : " https://registry.npmjs.org"
3131
32- - name : Verify version sync
33- env :
34- INPUT_VERSION : ${{ inputs.version }}
32+ - name : Verify version sync and export version
33+ id : version
3534 run : |
3635 node -e "
3736 const fs = require('node:fs');
3837 const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
3938 const jsr = JSON.parse(fs.readFileSync('jsr.json', 'utf8'));
40- const expected = process.env.INPUT_VERSION;
4139 if (pkg.version !== jsr.version) {
4240 throw new Error('package.json and jsr.json versions are not in sync');
4341 }
44- if (pkg.version !== expected) {
45- throw new Error('workflow input version does not match package.json/jsr.json version');
46- }
47- console.log('Version verified:', expected);
42+ fs.appendFileSync(process.env.GITHUB_OUTPUT, 'value=' + pkg.version + '\n');
43+ console.log('Version verified:', pkg.version);
4844 "
4945
5046 - name : Install dependencies
5147 run : bun install --frozen-lockfile
5248
49+ - name : Ensure version is unpublished
50+ env :
51+ VERSION : ${{ steps.version.outputs.value }}
52+ run : |
53+ if npm view "@sebastianwessel/quickjs@${VERSION}" version >/dev/null 2>&1; then
54+ echo "Version ${VERSION} is already published on npm."
55+ exit 1
56+ fi
57+
5358 - name : Lint
5459 run : bun run lint
5560
5863
5964 - name : Run tests (serial by file)
6065 run : |
61- set -e
62- for f in $(rg --files src | rg '\ .test\ .ts$ ' | sort); do
66+ set -euo pipefail
67+ for f in $(find src -type f -name '* .test.ts' | sort); do
6368 echo "Running $f"
6469 bun test "$f"
6570 done
6873 run : bun run build
6974
7075 - name : Publish to npm (trusted publishing)
76+ env :
77+ NODE_AUTH_TOKEN : " "
7178 run : npm publish --provenance --access public --ignore-scripts
7279
7380 - name : Publish to JSR
0 commit comments