-
Notifications
You must be signed in to change notification settings - Fork 267
Migrate NPM publishing to use trusted publishing instead of classic tokens #929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
@acalcutt Do you know of someone to ping to get the npm changes sorted? I wasn't involed with #907 but I'm assuming someone was able to create a token that unblocked releasing |
|
Maybe @rafaykh90 could help set up the since they had the permissions to publish. Someone with the rights needs to add the trusted publisher in npm settings. On my test package I set it up like this
I think here we could also limit it to the main environment |
|
@acalcutt I don't have the permissions to approve external contributors, as it need to go through the Security team. For now, I have updated the NPM token in the CI to publish new package version. Unfortunately, now token are valid upto 90 days only so it needs to be rotated again after that. Until the security team's review, we would have to work with that. Would it be possible to verify that the package is being published through the CI now? |
|
If we want to test the existing release workflow with the updated npm key, the version would need to be bumped. it only publishes when the version does not exist on npm. Basically following https://github.com/mapbox/node-pre-gyp/blob/master/RELEASE.md I could make a PR to bump to a prerelease to test if you wanted |
|
@acalcutt Feel free to do so. I just want to make sure that the CI is fixed for now and we are unblocked. |
|
Looks like the current workflow is working with the new NPM key https://github.com/mapbox/node-pre-gyp/actions/runs/20364041908 But i'd say keep this PR incase we get someone from mapbox who can add the npm permissions for trusted publisher |
|
I've approved the PR since the workflow looks good to me. But as @acalcutt said we should not |

NPM has sunset classic tokens as of December 9, 2025. This updates the release workflow to use OIDC-based trusted publishing instead. This could also help with our issue keeping the token up to date.
Changes
Workflow permissions
id-token: writepermission for OIDC token generationcontents: writeto top-level permissionsNPM authentication
npm config setandNPM_TOKENenv vars)registry-url: 'https://registry.npmjs.org'tosetup-nodeactionPackage configuration
package.jsonrepository URL fromgit://to HTTPS format (required for trusted publishing)Prerequisites for deployment
Before this workflow can be used, the NPM package must be configured for trusted publishing:
mapbox/node-pre-gyprepository andrelease.ymlworkflow as trusted sourcesThe workflow will then automatically receive and use OIDC tokens from GitHub Actions.
Benefits
References
Fixes #928