Skip to content

Commit a210b2a

Browse files
Fix npm publish workflow for trusted publishing (#143)
Cloeses o1-labs/o1js-site#3. Sibling of PR #142. ## Summary - Remove `registry-url` from `actions/setup-node`: it generates an `.npmrc` that conflicts with npm's OIDC trusted publishing authentication - Add `--provenance` to `npm publish`: signs the package with a build attestation linking it to this repo and workflow - Add `workflow_dispatch` trigger: allows manual publishes from the GitHub Actions UI - NOTE: - This PR does everything as PR [#142 ](#142.). However #142 didn't add `--provenance`. Without it, the `id-token: write` permission is set up but never actually used. The OIDC token gets requested but `npm publish` doesn't attach it as a signed attestation to the package. So it's a fix on top of what PR #142 had. ## Publishing process ### Pre-release steps 1. Bump the version in `package.json` (e.g. `npm version patch` / `minor` / `major`) 2. Commit the version bump 3. Tag the commit: `git tag v<version>` (e.g. `git tag v0.1.0`) 4. Push both: `git push origin main --tags` The workflow triggers automatically on the `v*` tag push. It will: 1. Install dependencies (`npm ci`) 2. Build the package (`npm run build`) 3. Run tests (`npm test`) 4. Publish to npm with provenance attestation Alternatively, you can trigger the workflow manually from the [Actions tab](../../actions/workflows/publish-npm.yml) using "Run workflow" on any branch. ### Prerequisites - npm trusted publishing must be configured for this package on npmjs.com, linking it to this GitHub repo (already done by Leon) - The version in `package.json` must not already be published on npm ## Test plan - [ ] Trigger workflow manually via `workflow_dispatch` to verify it authenticates and publishes correctly - [ ] Verify the published package on `npmjs.com` shows provenance information
1 parent 40ec094 commit a210b2a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

.github/workflows/publish-npm.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Publish Package
22

33
on:
4+
workflow_dispatch:
45
push:
56
tags:
67
- 'v*'
@@ -18,12 +19,11 @@ jobs:
1819
- uses: actions/setup-node@v4
1920
with:
2021
node-version: '20'
21-
registry-url: 'https://registry.npmjs.org'
2222

2323
# Ensure npm 11.5.1 or later is installed
2424
- name: Update npm
2525
run: npm install -g npm@latest
2626
- run: npm ci
2727
- run: npm run build --if-present
2828
- run: npm test
29-
- run: npm publish
29+
- run: npm publish --provenance

0 commit comments

Comments
 (0)