Skip to content

Verify npm token before version bump#1347

Closed
cristianrgreco wants to merge 1 commit into
mainfrom
codex/harden-npm-publish
Closed

Verify npm token before version bump#1347
cristianrgreco wants to merge 1 commit into
mainfrom
codex/harden-npm-publish

Conversation

@cristianrgreco
Copy link
Copy Markdown
Collaborator

@cristianrgreco cristianrgreco commented May 27, 2026

Summary

  • Verify the npm publish token before mutating release version files
  • Fail early when the release token is invalid, expired, or missing required registry access

Verification

  • ruby -e 'require "yaml"; YAML.load_file(".github/workflows/npm-publish.yml"); puts "yaml ok"'
  • git diff --check

Semver impact

Patch. This is release workflow-only maintenance and does not change package runtime behavior.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 27, 2026

Deploy Preview for testcontainers-node ready!

Name Link
🔨 Latest commit 81ba9d0
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-node/deploys/6a16f8aa17ae39000740966c
😎 Deploy Preview https://deploy-preview-1347--testcontainers-node.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@cristianrgreco cristianrgreco added maintenance Improvements that do not change functionality patch Backward compatible bug fix labels May 27, 2026 — with ChatGPT Codex Connector
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ff8c1ea25

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/npm-publish.yml Outdated
Comment on lines 105 to 106
if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.publish) }}
run: npm publish --ws
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 Persist version bump before manual publish

When workflow_dispatch is run with publish: true, this step publishes after the local Update versions mutation, but the commit and push steps above are still guarded with github.event_name == 'release'. For a manual publish of a new version, npm receives package tarballs with updated package.json/lockfile/sonar metadata that are never recorded on main, leaving the repository behind the published artifacts and making the next release/rerun operate from stale version files. Either persist the bump for the manual publish path or require this path to run only when the selected ref already contains the version bump.

Useful? React with 👍 / 👎.

@cristianrgreco cristianrgreco force-pushed the codex/harden-npm-publish branch from 8ff8c1e to 81ba9d0 Compare May 27, 2026 13:59
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 81ba9d00ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- 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 👍 / 👎.

@cristianrgreco cristianrgreco changed the title Harden npm publish workflow reruns Verify npm token before version bump May 27, 2026
@cristianrgreco cristianrgreco deleted the codex/harden-npm-publish branch May 27, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Improvements that do not change functionality patch Backward compatible bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant