ci(release): npm and crates.io via OIDC trusted publishing#13
Merged
Conversation
Extend OIDC trusted publishing to the npm and crates.io release jobs, removing the long-lived NPM_TOKEN and CARGO_REGISTRY_TOKEN from the release path (the PyPI job already moved to OIDC). As with PyPI, tree-sitter/workflows' package-npm.yml and package-crates.yml require their token secrets and expose no id-token permission, and the upstream fix (tree-sitter/workflows#54) is an unmerged draft, so both are vendored here with that patch applied and adapted per registry: - npm: the auth token is optional and the publish job carries id-token: write. npm is upgraded to a trusted-publishing-capable release (>= 11.5.1) before publish, since the bundled npm predates OIDC support. When NODE_AUTH_TOKEN is unset, npm publish authenticates through the OIDC id-token. - crates.io: the registry token is optional and the publish job carries id-token: write. When no token is set, rust-lang/crates-io-auth-action mints a short-lived token via OIDC, which cargo publish then uses. release.yml calls the local copies, grants contents: read + id-token: write to each reusable workflow, and no longer passes the token secrets. Both require a GitHub trusted publisher configured on the respective registry (workflow release.yml; environments npm and crates). Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends OIDC trusted publishing to the npm and crates.io release jobs, removing the long-lived
NPM_TOKENandCARGO_REGISTRY_TOKENfrom the release path. The PyPI job already moved to OIDC onmain.Approach
tree-sitter/workflows'package-npm.ymlandpackage-crates.ymlrequire their token secrets and expose noid-tokenpermission, and a caller cannot inject permissions into a reusable workflow's internal jobs. The upstream fix (tree-sitter/workflows#54) is an unmerged draft, so both workflows are vendored here with that patch applied and adapted per registry:id-token: write; npm is upgraded to a trusted-publishing-capable release (>= 11.5.1) before publish, since the bundled npm predates OIDC support. WithNODE_AUTH_TOKENunset,npm publishauthenticates through the OIDC id-token.id-token: write. With no token set,rust-lang/crates-io-auth-actionmints a short-lived token via OIDC, whichcargo publishthen uses.release.ymlcalls the local copies, grantscontents: read+id-token: writeto each reusable workflow, and no longer passes the token secrets.Requires
A GitHub trusted publisher configured on each registry before the next release: workflow
release.yml, environmentsnpmandcratesrespectively. Until each publish is confirmed green, the classic token secrets can remain as a rollback (setting the secret re-enables token auth without a workflow change).