Skip to content

Commit 5ae04db

Browse files
ci(npm): build + provenance in npm-publish workflow
1 parent c923734 commit 5ae04db

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.github/workflows/npm-publish.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ jobs:
1111
runs-on: ubuntu-latest
1212
permissions:
1313
contents: read
14+
id-token: write
15+
16+
env:
17+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1418

1519
steps:
1620
- name: Checkout repository
@@ -22,10 +26,14 @@ jobs:
2226
node-version: "20"
2327
cache: "npm"
2428
registry-url: https://registry.npmjs.org
29+
scope: "@programinglive"
2530

2631
- name: Install dependencies
2732
run: npm ci
2833

34+
- name: Build package
35+
run: npm run build
36+
2937
- name: Verify tag matches package version
3038
run: |
3139
EXPECTED_TAG="${GITHUB_REF#refs/tags/}"
@@ -36,6 +44,4 @@ jobs:
3644
fi
3745
3846
- name: Publish to npm
39-
run: npm publish
40-
env:
41-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
47+
run: npm publish --provenance

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ This repository ships with `.github/workflows/npm-publish.yml`, which publishes
295295
1. Create an npm automation token with publish rights (`npm token create --read-only false`).
296296
2. In the repository settings, add a secret named **`NPM_TOKEN`** containing that token.
297297
3. Ensure your release process pushes tags after running `npm run release:<type>` so the workflow triggers.
298+
4. Confirm `npm run build` succeeds locally; the workflow runs the build before publishing so broken bundles block the release.
299+
5. GitHub provenance is enabled via `npm publish --provenance`. Leave GitHub Actions' default OIDC permissions enabled so the job can request an ID token.
298300

299301
The workflow verifies that the tag version matches `package.json` before publishing and fails fast if they diverge.
300302

0 commit comments

Comments
 (0)