chore: configure npm Trusted Publishers (OIDC) for publish workflows#975
chore: configure npm Trusted Publishers (OIDC) for publish workflows#975
Conversation
…974) Migrate npm publish authentication from static NPM_TOKEN secrets to npm Trusted Publishers (OIDC), eliminating long-lived tokens in favor of short-lived OIDC tokens automatically generated by GitHub Actions. - Create unified workflow combining release and snapshot publish jobs - Use id-token: write permission for OIDC authentication - Conditionally upgrade npm to >=11.5.1 (required for OIDC support) - Improve GPG signing setup (gpg-agent, loopback-pinentry, preset-passphrase) - Use annotated + signed git tags - Include packages/*/package.json in release commits - Set NPM_CONFIG_PROVENANCE to false - Remove old code-npm_node-release.yml and code-npm_node-publish_snapshot.yml
There was a problem hiding this comment.
Pull request overview
This PR migrates npm publish authentication from static NPM_TOKEN secrets to npm Trusted Publishers (OIDC), combining the previously separate release and snapshot publish workflows into a single unified workflow file. This eliminates long-lived npm tokens in favor of short-lived OIDC tokens automatically generated by GitHub Actions.
Changes:
- Created
.github/workflows/code-npm_node-publish-release-and-snapshot.ymlcombining both publish jobs withid-token: writepermissions, conditional npm upgrade to >= 11.5.1, improved GPG signing setup, and annotated/signed git tags - Deleted the separate
.github/workflows/code-npm_node-publish_snapshot.ymland.github/workflows/code-npm_node-release.ymlworkflows - Removed all references to
NPM_TOKEN/NODE_AUTH_TOKENsecrets in favor of OIDC-based authentication
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
.github/workflows/code-npm_node-publish-release-and-snapshot.yml |
New unified workflow with OIDC auth, npm version upgrade, improved GPG setup, and both snapshot + release jobs |
.github/workflows/code-npm_node-publish_snapshot.yml |
Deleted — snapshot publishing moved to the unified workflow |
Comments suppressed due to low confidence (3)
.github/workflows/code-npm_node-publish-release-and-snapshot.yml:5
- The concurrency key
code-publish-${{ github.ref }}is now shared between both thepublish-snapshotandreleasejobs. Forissue_commentevents,github.refresolves to the default branch (e.g.,refs/heads/main), not the PR branch. This means a snapshot publish triggered via PR comment could cancel an in-progress release job (or vice versa), since they'd share the same concurrency groupcode-publish-refs/heads/main.
Previously, the snapshot workflow used code-publish-snapshot-${{ github.ref }} and the release workflow used code-release-${{ github.ref }}, so they could not interfere with each other. Consider using job-level concurrency groups instead (e.g., code-publish-snapshot-... and code-publish-release-...) to restore the isolation.
.github/workflows/code-npm_node-publish-release-and-snapshot.yml:133
- The
publish-snapshotjob is missing theNPM / Create Cache Foldersstep (mkdir -p "$HOME"/.npm) that exists in thereleasejob (line 316-318) and was present in the old snapshot workflow. While this may not always cause a failure (the directory might already exist), it's inconsistent with the release job and could cause issues if the.npmcache directory doesn't exist.
.github/workflows/code-npm_node-publish-release-and-snapshot.yml:185 - The
publish-snapshotjob's publish step (line 180-185) does not setNPM_CONFIG_PROVENANCE: "false", unlike the release job (line 390). Since both jobs now use npm >= 11.5.1 with OIDC (id-token: write), npm may automatically attempt to generate provenance attestations during snapshot publishing. If provenance should be explicitly disabled (as stated in the PR description), this env var should be set here as well for consistency.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Move permissions from workflow-level to job-level (SonarQube) - Restore job-level concurrency groups to prevent snapshot/release interference on issue_comment events - Add missing NPM / Create Cache Folders step to publish-snapshot job - Add NPM_CONFIG_PROVENANCE: false to snapshot publish step
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Replace code-npm_node-release.md with code-npm_node-publish-release-and-snapshot.md reflecting OIDC authentication, GPG signing, snapshot job, and job-level permissions.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
.github/workflows/code-npm_node-publish-release-and-snapshot.yml
Outdated
Show resolved
Hide resolved
.github/workflows/code-npm_node-publish-release-and-snapshot.yml
Outdated
Show resolved
Hide resolved
- Restore asdf cache-hit guard on both jobs to skip install on cache hit - Fix "Github" -> "GitHub" in release step name and error message
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Proof of testingValidated on InditexTech/npm-release-testing with the same workflow configuration: |
|



Closes #974
Summary
Migrate npm publish authentication from static
NPM_TOKENsecrets to npm Trusted Publishers (OIDC), eliminating long-lived tokens in favor of short-lived OIDC tokens automatically generated by GitHub Actions.Changes
New unified workflow
.github/workflows/code-npm_node-publish-release-and-snapshot.ymlid-token: writepermission for OIDC authentication (noNPM_TOKEN/NODE_AUTH_TOKEN)>=11.5.1(required for Trusted Publishing support)packages/*/package.jsonNPM_CONFIG_PROVENANCEexplicitly set to"false"Removed workflows
.github/workflows/code-npm_node-release.yml.github/workflows/code-npm_node-publish_snapshot.ymlNot affected
.github/workflows/code-release_preview.yml— works independentlynpm/Node compatibility
code/.tool-versions)References
InditexTech/npm-release-testing