ci: publish to npm via trusted publishing instead of a stored token - #549
Conversation
The crates.io job has been using trusted publishing for a while, but the two npm jobs still authenticated with `secrets.NPM_TOKEN` — they set `//registry.npmjs.org/:_authToken` from it and only used `id-token: write` to attest provenance. So a long-lived npm credential with publish rights to the whole scope sat in the repository's secrets, which is the thing trusted publishing exists to remove. Dropping the token is the whole change: npm 11.5.1+ detects the Actions OIDC token on its own, exchanges it for a short-lived publish credential, and generates provenance automatically on that path. The `npm install -g` pin moves from `npm@11` to `npm@^11.5.1` to state the version that behavior needs. The `--provenance` flags stay: they are redundant under trusted publishing but keep the intent visible, and `publishConfig.provenance` already requests it anyway. The `npm` environment is now load-bearing rather than decorative. A trusted publisher entry names the repository, the workflow file, and the environment, so all three are part of the identity — renaming any of them stops publishing until every package's entry is updated. Both are called out where they appear. Trusted publishing cannot create a package that does not exist yet, because the publisher entry lives on the package's settings page. `release.md` now documents that bootstrap step for npm alongside the equivalent crates.io one, including the version-bump-before-pack detail that decides whether the tarball pins its `@ox-content/*` dependencies to the right release. Setup this needs before the next tag: a trusted publisher entry per package on npmjs.com, and `NPM_TOKEN` can be revoked once they are in place.
|
Warning Review limit reached
Next review available in: 6 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
@ox-content/binding-darwin-arm64
@ox-content/binding-darwin-x64
@ox-content/binding-linux-arm64-gnu
@ox-content/binding-linux-arm64-musl
@ox-content/binding-linux-x64-gnu
@ox-content/binding-linux-x64-musl
@ox-content/binding-win32-x64-msvc
@ox-content/napi
@ox-content/islands
@ox-content/unplugin
@ox-content/vite-plugin
@ox-content/vite-plugin-react
@ox-content/vite-plugin-solid
@ox-content/vite-plugin-svelte
@ox-content/vite-plugin-vue
commit: |
Benchmark report3 runtime rows and 5 bundle rows compared. Comparing base Runtime
Values are from the large runtime benchmarks. Time is shown in milliseconds to microsecond precision. Head speed is normalized with base = 1.00 (100%); changes within +/-5% are treated as noise. Competitive Snapshot
This snapshot uses the head commit and the same input corpus as the regression gate. Higher runtime ops/sec is better. Environment
Bundle Size
Bundle size uses gzipped JS/CSS/HTML/JSON assets. Requests estimate index.html plus referenced local initial assets. Lower is better. Regression GateRuntime regressions fail when head throughput is more than 10% slower than base (async rows are informational only; their worker-scheduling variance exceeds the threshold on quiet PRs). Bundle regressions fail when gzipped size grows by more than 5%. Maintainers can intentionally override by applying the No threshold regressions found. |
The crates.io job has used trusted publishing for a while. The two npm jobs had not — they set
//registry.npmjs.org/:_authTokenfromsecrets.NPM_TOKENand only usedid-token: writeto attest provenance. A long-lived npm credential with publish rights across the whole scope was sitting in the repository's secrets, which is precisely what trusted publishing removes.The change
Dropping the token is the whole thing. npm 11.5.1+ detects the Actions OIDC token itself, exchanges it for a short-lived publish credential, and generates provenance automatically on that path.
env.NODE_AUTH_TOKENand thenpm config set …_authTokenline from both npm jobsnpm install -g npm@11→npm@11.19.0, an exact pin (zizmor'sadhoc-packagesaudit rejects ranges) above the 11.5.1 that behavior actually requires--provenanceflags: redundant under trusted publishing, but they keep the intent visible andpublishConfig.provenancerequests it regardlessThe
npmenvironment is now load-bearing rather than decorative — a trusted publisher entry names the repository, the workflow file, and the environment, so renaming any of the three stops publishing until every package's entry is updated. Both facts are commented where they appear.Required setup before the next tag
This does not work until each package has a trusted publisher entry on npmjs.com pointing at this repo,
.github/workflows/publish.yml, and thenpmenvironment:@ox-content/napi,@ox-content/islands,@ox-content/vite-plugin,@ox-content/unplugin@ox-content/vite-plugin-{vue,react,svelte,solid}@ox-content/wasm@ox-content/napi-*platform binding packageOnce they are in place,
NPM_TOKENcan be revoked.The bootstrap caveat, documented
Trusted publishing cannot create a package that does not exist yet — the publisher entry is configured on the package's settings page, so the package has to be there first. Same shape as the crates.io restriction already documented below it.
release.mdnow covers that step for npm, including the detail that bit during this release: bump every workspace package to the release version before packing, or the tarball pins its@ox-content/*dependencies to the previous version.This is why
@ox-content/vite-plugin-solidstill needs one manual publish before v2.82.0 is tagged.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is enabled.