Skip to content

ci: publish to npm through trusted publishing with staged releases - #525

Merged
RobertLD merged 1 commit into
mainfrom
ci/npm-staged-publish
Oct 9, 2026
Merged

RobertLD merged 1 commit into
mainfrom
ci/npm-staged-publish

Conversation

@RobertLD

@RobertLD RobertLD commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Problem

The 2.0.0 publish job failed twice with E404 Not Found - PUT https://registry.npmjs.org/libscope (run 37831881935). NPM_TOKEN was last set on 2026-03-01 and has expired. 2.0.0 is tagged and released on GitHub but not on npm.

Change

The npm trusted publisher for this repo is now configured for release-please.yml with only npm stage publish allowed. This PR switches the publish job to match:

  • npm install -g npm@11: the runner's npm 10.9.9 does not do the OIDC exchange, and npm stage publish needs npm >= 11.15.0.
  • npm publish --provenance --access public with NODE_AUTH_TOKEN → npm stage publish. Trusted publishing adds provenance itself.
  • A workflow_dispatch trigger with a required tag input. The publish job checks out that tag, so an existing release can be published.

After merge

  1. gh workflow run release-please.yml -R RobertLD/libscope -f tag=v2.0.0
  2. Approve the staged 2.0.0 on npmjs.com with 2FA. This publish also validates the trusted publisher, which must happen before 2026-10-11 17:09 UTC.
  3. gh secret delete NPM_TOKEN -R RobertLD/libscope

Not verified

  • That a staged publish counts as the validating publish.
  • That the trusted publisher accepts a workflow_dispatch run. npm checks the repo and workflow file name.

Either failure would stop at npm before anything goes live.

The 2.0.0 publish failed with E404 because NPM_TOKEN expired. Publish
through the trusted publisher instead, which allows only
`npm stage publish`:

- Install npm 11; the runner's npm 10 cannot do the OIDC exchange.
- Replace `npm publish` and NODE_AUTH_TOKEN with `npm stage publish`.
  Trusted publishing adds provenance itself.
- Add a workflow_dispatch trigger with a tag input, to publish a tag
  whose release already exists (v2.0.0).
@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
libscope Ignored Ignored Oct 9, 2026 5:12pm UTC

@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@RobertLD
RobertLD merged commit 4d04013 into main Oct 9, 2026
7 of 8 checks passed
@RobertLD
RobertLD deleted the ci/npm-staged-publish branch October 9, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant