Skip to content

Commit 8adbe6f

Browse files
Copilotcompulim
andauthored
Use OIDC for npm publishing in publish-release.yml (#450)
* Initial plan * Modify publish-release.yml to use OIDC authentication Co-authored-by: compulim <1622400+compulim@users.noreply.github.com> * Add version validation step from continuous-deployment.yml Co-authored-by: compulim <1622400+compulim@users.noreply.github.com> * Fix step field order: name before if Co-authored-by: compulim <1622400+compulim@users.noreply.github.com> * Revert "Add version validation step from continuous-deployment.yml" Co-authored-by: compulim <1622400+compulim@users.noreply.github.com> * Reformat publish-release workflow for clarity --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: compulim <1622400+compulim@users.noreply.github.com> Co-authored-by: William Wong <compulim@users.noreply.github.com>
1 parent 8ce4273 commit 8adbe6f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

.github/workflows/publish-release.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,19 @@ jobs:
4444
GH_TOKEN: ${{ github.token }}
4545

4646
publish-package:
47-
environment: production
47+
environment:
48+
name: npm
49+
url: https://npmjs.com/package/${{ steps.get-version.outputs.package-name }}/v/${{ steps.get-version.outputs.version }}
4850
needs: build-and-draft
4951
runs-on: ubuntu-latest
52+
permissions:
53+
contents: read
54+
id-token: write
5055

5156
steps:
5257
- uses: actions/setup-node@v3
5358
with:
54-
node-version: 18
59+
node-version: 24 # Newer Node.js version for OIDC publishing
5560
registry-url: https://registry.npmjs.org/
5661
- name: Download tarball artifact
5762
uses: actions/download-artifact@v4.2.1
@@ -63,8 +68,6 @@ jobs:
6368
echo package-name=`tar --extract --file=\`ls ./*.tgz\` --to-stdout package/package.json | jq -r .name` >> $GITHUB_OUTPUT
6469
echo version=`tar --extract --file=\`ls ./*.tgz\` --to-stdout package/package.json | jq -r .version` >> $GITHUB_OUTPUT
6570
- run: npm publish --access public `ls ./*.tgz`
66-
env:
67-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6871
- name: Generate job summary
6972
run: echo "NPM package has been published to https://npmjs.com/package/${{ steps.get-version.outputs.package-name }}/v/${{ steps.get-version.outputs.version }}." > $GITHUB_STEP_SUMMARY
7073

0 commit comments

Comments
 (0)