Skip to content

Commit 5b47043

Browse files
committed
chore(workflow): implement trusted npm publishing in GitHub Actions
- Updated the publish command in .releaserc.json to use an environment variable for the npm command, enhancing security for trusted publishing. - Added a step in the publish-to-npm-alpha.yml workflow to resolve the trusted npm command and set it as an environment variable.
1 parent 1471464 commit 5b47043

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

.github/workflows/publish-to-npm-alpha.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ jobs:
2424
registry-url: "https://registry.npmjs.org"
2525
- name: Upgrade npm for trusted publishing
2626
run: npm install -g npm@11.6.2
27+
- name: Resolve trusted publishing npm
28+
run: |
29+
echo "TRUSTED_PUBLISH_NPM=$(command -v npm)" >> "$GITHUB_ENV"
30+
"$(command -v npm)" --version
2731
- name: Show runtime versions
2832
run: node --version && npm --version
2933
- name: Install dependencies

.releaserc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"@semantic-release/commit-analyzer",
88
"@semantic-release/release-notes-generator",
99
["@semantic-release/npm", { "npmPublish": false }],
10-
["@semantic-release/exec", { "publishCmd": "npm publish --provenance --access public --loglevel verbose" }],
10+
["@semantic-release/exec", { "publishCmd": "\"$TRUSTED_PUBLISH_NPM\" publish --provenance --access public --loglevel verbose" }],
1111
"@semantic-release/github"
1212
]
1313
}

0 commit comments

Comments
 (0)