-
Notifications
You must be signed in to change notification settings - Fork 18
Migrate NPM publishing to OIDC trusted publishing #3949
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ name: Publish package on NPM | |
|
|
||
| permissions: | ||
| contents: write | ||
| id-token: write # Required for OIDC trusted publishing | ||
|
|
||
| on: | ||
| release: | ||
|
|
@@ -15,9 +16,10 @@ jobs: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
| with: | ||
| fetch-depth: 1 | ||
| - uses: actions/setup-node@v3 | ||
| - uses: actions/setup-node@v4 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GitHub will force Node 24 in June 2026 so I took the opportunity to bump the version |
||
| with: | ||
| node-version: 18 | ||
| node-version: 24 | ||
| registry-url: 'https://registry.npmjs.org' | ||
| - name: Releasing tag ${{ github.event.release.tag_name }} | ||
| run: | | ||
| corepack enable; yarn | ||
|
|
@@ -29,24 +31,10 @@ jobs: | |
| cd $(echo $tag_name | rev | cut -d'/' -f2- | rev) | ||
| fi | ||
|
|
||
| yarn_major_version=$(yarn --version | cut -d'.' -f1) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. npm publish is the only officially supported path for OIDC trusted publishing. |
||
| if [ "$yarn_major_version" -ge 2 ] && [ "$yarn_major_version" -le 4 ]; then | ||
| cmd="yarn npm publish --access public" | ||
| elif [ "$yarn_major_version" -eq 1 ]; then | ||
| cmd="yarn publish --access public" | ||
| else | ||
| echo "Unsupported Yarn version: $yarn_major_version" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "${{ github.event.release.prerelease }}" == "true" ]; then | ||
| cmd+=" --tag=beta" | ||
| npm publish --provenance --access public --tag beta | ||
| else | ||
| cmd+=" --tag=latest" | ||
| npm publish --provenance --access public --tag latest | ||
| fi | ||
|
|
||
| eval $cmd | ||
| env: | ||
| NPM_AUTH_TOKEN: ${{ secrets.YARN_NPM_AUTH_TOKEN }} | ||
| YARN_NPM_AUTH_TOKEN: ${{ secrets.YARN_NPM_AUTH_TOKEN }} | ||
| COREPACK_ENABLE_DOWNLOAD_PROMPT: 0 | ||
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.
Without this, GitHub Actions can't generate the OIDC token that npm needs