-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Update npm-publish.yml to use trusted publishing #3083
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: main
Are you sure you want to change the base?
Conversation
| - run: npm ci | ||
| # It is recommend to publish to npm using trusted publishing; for details, | ||
| # see: https://docs.npmjs.com/trusted-publishers | ||
| - run: npm publish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to leave the token commented out, as a fallback for GHES, and GHEC w/ data residency.
| - run: npm publish | |
| - run: npm publish | |
| env: | |
| # An explicit token is needed only for non-github.com workflows. | |
| # NODE_AUTH_TOKEN: ${{secrets.npm_token}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a bare env: will cause an error, but I pushed up a riff on this suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the npm-publish.yml starter workflow to use npm's trusted publishing feature instead of requiring manual token management. This change improves security by eliminating the need to store and manage npm access tokens as secrets.
- Adds required
id-token: writepermission for trusted publishing - Updates npm to ensure compatibility with trusted publishing (requires npm 11.5.1+)
- Removes the env block that used manual tokens and adds commented fallback instructions
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
ci/npm-publish.yml
Outdated
| - name: Update npm | ||
| run: npm install -g npm@latest | ||
| - run: npm ci | ||
| # It is recommend to publish to npm using trusted publishing; for details, |
Copilot
AI
Oct 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected grammar from 'It is recommend' to 'It is recommended'.
| # It is recommend to publish to npm using trusted publishing; for details, | |
| # It is recommended to publish to npm using trusted publishing; for details, |
hashtagchris
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
thboop
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Pre-requisites
Please note that at this time we are only accepting new starter workflows for Code Scanning. Updates to existing starter workflows are fine.
Tasks
For all workflows, the workflow:
.ymlfile with the language or platform as its filename, in lower, kebab-cased format (for example,docker-image.yml). Special characters should be removed or replaced with words as appropriate (for example, "dotnet" instead of ".NET").GITHUB_TOKENso that the workflow runs successfully.For CI workflows, the workflow:
cidirectory.ci/properties/*.properties.jsonfile (for example,ci/properties/docker-publish.properties.json).pushtobranches: [ $default-branch ]andpull_requesttobranches: [ $default-branch ].releasewithtypes: [ created ].docker-publish.yml).For Code Scanning workflows, the workflow:
code-scanningdirectory.code-scanning/properties/*.properties.jsonfile (for example,code-scanning/properties/codeql.properties.json), with properties set as follows:name: Name of the Code Scanning integration.creator: Name of the organization/user producing the Code Scanning integration.description: Short description of the Code Scanning integration.categories: Array of languages supported by the Code Scanning integration.iconName: Name of the SVG logo representing the Code Scanning integration. This SVG logo must be present in theiconsdirectory.pushtobranches: [ $default-branch, $protected-branches ]andpull_requesttobranches: [ $default-branch ]. We also recommend ascheduletrigger ofcron: $cron-weekly(for example,codeql.yml).Some general notes:
actionsorganization, or