Skip to content

Commit 9ca82b8

Browse files
ci: simplify release trigger and harden publish workflow
1 parent d005c73 commit 9ca82b8

2 files changed

Lines changed: 19 additions & 18 deletions

File tree

.github/workflows/pull_request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ jobs:
2727
bun run build
2828
- name: Test
2929
run: |
30-
set -e
30+
set -euo pipefail
3131
bunx tsc --noEmit
32-
for f in $(rg --files src | rg '\.test\.ts$' | sort); do
32+
for f in $(find src -type f -name '*.test.ts' | sort); do
3333
echo "Running $f"
3434
bun test "$f"
3535
done

.github/workflows/release.yml

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ name: Release
22

33
on:
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

116
permissions:
127
contents: read
@@ -27,29 +22,33 @@ jobs:
2722
uses: actions/setup-node@v4
2823
with:
2924
node-version: 22
30-
registry-url: "https://registry.npmjs.org"
3125

32-
- name: Verify version sync
33-
env:
34-
INPUT_VERSION: ${{ inputs.version }}
26+
- name: Verify version sync and export version
27+
id: version
3528
run: |
3629
node -e "
3730
const fs = require('node:fs');
3831
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
3932
const jsr = JSON.parse(fs.readFileSync('jsr.json', 'utf8'));
40-
const expected = process.env.INPUT_VERSION;
4133
if (pkg.version !== jsr.version) {
4234
throw new Error('package.json and jsr.json versions are not in sync');
4335
}
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);
36+
fs.appendFileSync(process.env.GITHUB_OUTPUT, 'value=' + pkg.version + '\n');
37+
console.log('Version verified:', pkg.version);
4838
"
4939
5040
- name: Install dependencies
5141
run: bun install --frozen-lockfile
5242

43+
- name: Ensure version is unpublished
44+
env:
45+
VERSION: ${{ steps.version.outputs.value }}
46+
run: |
47+
if npm view "@sebastianwessel/quickjs@${VERSION}" version >/dev/null 2>&1; then
48+
echo "Version ${VERSION} is already published on npm."
49+
exit 1
50+
fi
51+
5352
- name: Lint
5453
run: bun run lint
5554

@@ -58,8 +57,8 @@ jobs:
5857

5958
- name: Run tests (serial by file)
6059
run: |
61-
set -e
62-
for f in $(rg --files src | rg '\.test\.ts$' | sort); do
60+
set -euo pipefail
61+
for f in $(find src -type f -name '*.test.ts' | sort); do
6362
echo "Running $f"
6463
bun test "$f"
6564
done
@@ -68,6 +67,8 @@ jobs:
6867
run: bun run build
6968

7069
- name: Publish to npm (trusted publishing)
70+
env:
71+
NODE_AUTH_TOKEN: ""
7172
run: npm publish --provenance --access public --ignore-scripts
7273

7374
- name: Publish to JSR

0 commit comments

Comments
 (0)