ci: add OIDC permissions for npm trusted publishing #434
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.
Summary
Enable npm trusted publishing with OpenID Connect (OIDC) by adding the required permissions to the GitHub Actions publish workflow.
What is npm Trusted Publishing?
npm trusted publishing allows packages to be published directly from CI/CD workflows without storing long-lived authentication tokens. Instead:
Changes Made
publish.yml Updates
Added job-level permissions to the
publishjob:Added comment explaining automatic OIDC handling by npm CLI.
Security Benefits
✅ Eliminates token exposure risk - No long-lived tokens stored in secrets
✅ Automatic provenance - npm CLI v11.5.1+ automatically generates package provenance attestations
✅ Unique per-publish - Each publish uses a different, short-lived token
✅ No manual rotation - Tokens are automatically managed by GitHub Actions
✅ Cannot be reused - Tokens are cryptographically bound to specific workflows
How It Works
Prerequisites Verified
✅ npm CLI v11.5.1 or later (already in use via node 22.x)
✅ GitHub-hosted runners (using ubuntu-latest)
✅ Trusted publisher configured on npmjs.com (user confirmed)
✅ Standard node_modules/.bin/npm available in workflow
Testing
This change only adds permissions - the actual OIDC token handling is automatic in npm CLI v11.5.1+. The workflow will continue to work with the fallback NPM_AUTH_TOKEN for older npm versions, while newer npm versions will prioritize the OIDC token.
References
🤖 Generated with Claude Code
Note
Add
id-token: writeandcontents: readpermissions to thepublishjob in.github/workflows/publish.ymlto enable npm trusted publishing via OIDC..github/workflows/publish.yml): Add job-level permissionsid-token: writeandcontents: readto enable npm trusted publishing via OIDC.Written by Cursor Bugbot for commit db5674a. This will update automatically on new commits. Configure here.