DX-2278: update release to use npm OIDC#149
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR migrates the npm release workflow from traditional token-based authentication to OIDC (OpenID Connect) authentication, following npm's trusted publishers documentation. The change enhances security by eliminating the need to store long-lived npm tokens as secrets.
Changes:
- Add OIDC permissions (
id-token: writeandcontents: read) to enable GitHub Actions OIDC authentication - Update GitHub Actions to newer versions (checkout@v4, setup-node@v4) and configure npm registry URL
- Remove manual npm token authentication step in favor of OIDC
- Update Node.js version from 18 to 24
Comments suppressed due to low confidence (1)
.github/workflows/release.yml:49
- The publish steps are missing the NODE_AUTH_TOKEN environment variable required for OIDC authentication. When using registry-url with actions/setup-node for OIDC authentication, npm publish commands need to have NODE_AUTH_TOKEN set. Add the environment variable to both publish steps:
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
This environment variable tells npm to use the OIDC token generated by GitHub Actions for authentication with the npm registry.
- name: Publish release candidate
if: "github.event.release.prerelease"
run: npm publish --access public --tag=canary --no-git-checks
- name: Publish
if: "!github.event.release.prerelease"
run: npm publish --access public --no-git-checks
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
for more details, see upstash/ratelimit-js#149
check https://docs.npmjs.com/trusted-publishers and upstash/ratelimit-js#149 for details
check https://docs.npmjs.com/trusted-publishers and upstash/ratelimit-js#149 for details
check upstash/ratelimit-js#149 for more details
Check upstash/ratelimit-js#149 for more details
Check upstash/ratelimit-js#149 for more details
Check upstash/ratelimit-js#149 for more details
* fix: use npm OIDC Check upstash/ratelimit-js#149 for more details * fix: repository.url to fix provenance check * fix: fmt
* feat: use npm OIDC check upstash/ratelimit-js#149 for more details * fix: await indexing in test
* feat: use npm OIDC for more details, see upstash/ratelimit-js#149 * fix: add sleep between cursor requests * fix: simplify cursor tests * fix: flaky test
NPM OIDC Migration Instructions
Migrate npm publishing from
NPM_TOKENto npm OIDC with provenance attestation.Prerequisites
Configure npm trusted publishers on npmjs.com:
upstash/<package-name>ci.yml(the router workflow)Changes
1.
package.jsonAdd
repositoryfield (required for npm provenance):2. Create
.github/workflows/ci.ymlCreate a router workflow that calls tests and release workflows. npm OIDC only allows one workflow file to have publish permission, so both workflows must be called from this single router.
pull_request,release.published,scheduleid-token: write,contents: readtests: runs on non-release events, callstests.yamlwithsecrets: inheritrelease: runs on release events, callsrelease.ymlwithprerelease: ${{ github.event.release.prerelease }}input andsecrets: inherit3. Update
.github/workflows/release.ymlrelease.publishedtoworkflow_callwithprereleaseboolean inputactions/checkouttov4actions/setup-nodetov4withnode-version: 24and addregistry-url: https://registry.npmjs.org.npmrc--provenanceflag to allnpm publishcommandsgithub.event.release.prereleasetoinputs.prerelease4. Update
.github/workflows/tests.yamlpull_request/scheduletoworkflow_callactions/checkouttov4actions/setup-nodetov4withnode-version: 24and addregistry-url: https://registry.npmjs.org.npmrc--provenanceflag tonpm publishcommand5. Changes in Repo Settings on Github
Summary
NPM_TOKENin .npmrcregistry-urlin setup-nodenpm publishnpm publish --provenanceactions/checkout@v3actions/checkout@v4actions/setup-node@v2/v3actions/setup-node@v4workflow_call+ router ci.yml