Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ jobs:
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"

- name: Verify npm publish token
if: ${{ github.event_name == 'release' }}
run: |
if npm whoami > /dev/null 2>&1; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use a publish-permission check before pushing

For release runs where secrets.npm_token is a valid but non-publishing token, such as a read-only or wrong-scope granular npm token, npm whoami still authenticates successfully; I checked npm whoami --help, which only says it displays the npm username, and npm’s token docs distinguish read-only from read/write package permissions. In this workflow that means the job can still reach the guarded Git commit/Git push steps before npm publish --ws fails, leaving the version bump pushed without published packages, so this needs to verify actual publish access or move the mutation push after a publish-capable check.

Useful? React with 👍 / 👎.

echo "npm publish token is valid"
else
echo "::error::npm publish token is invalid, expired, or missing required registry access"
exit 1
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}

- name: Update versions
env:
TAG: ${{ steps.version.outputs.tag }}
Expand Down