Skip to content

Commit 616af5f

Browse files
Merge pull request #102 from sebastianwessel/codex/release-workflow-hardening
CI: remove release version input and fix trusted publish
2 parents 5c99e31 + 02a4963 commit 616af5f

2 files changed

Lines changed: 25 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: 23 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
@@ -17,6 +12,12 @@ jobs:
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

@@ -58,8 +63,8 @@ jobs:
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
@@ -68,6 +73,8 @@ jobs:
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

Comments
 (0)