Skip to content

Commit 91f4682

Browse files
committed
fix(ci): gate trusted npm publish by NPM_PUBLISH
1 parent d94691c commit 91f4682

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

.github/workflows/build_release.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,16 @@ jobs:
178178
exit 1
179179
fi
180180
181-
- name: Publish npm
181+
- name: Publish npm (Trusted publishing)
182182
run: |
183-
echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
184-
185-
if [ -z "${{ secrets.NPM_TOKEN }}" ]; then
186-
echo "NPM_TOKEN not set, performing dry run"
187-
pnpm publish --dry-run --no-git-checks --access public
183+
if [ "${{ secrets[format('{0}', 'NPM_PUBLISH')] }}" = "yes" ]; then
184+
echo "NPM_PUBLISH=yes, publishing to npm with trusted publishing..."
185+
pnpm publish --no-git-checks --access public --provenance
188186
else
189-
echo "Publishing to npm..."
190-
pnpm publish --no-git-checks --access public
187+
echo "NPM_PUBLISH is not yes, performing dry run"
188+
pnpm publish --dry-run --no-git-checks --access public
191189
fi
192-
env:
193-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
194190
195191
permissions:
196192
contents: write
193+
id-token: write

0 commit comments

Comments
 (0)