Skip to content

ci(release): switch npm publish to OIDC Trusted Publishing - #161

Merged
antosubash merged 2 commits into
mainfrom
fix-release
May 21, 2026
Merged

ci(release): switch npm publish to OIDC Trusted Publishing#161
antosubash merged 2 commits into
mainfrom
fix-release

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Summary

  • The NPM_TOKEN granular access token expired between v0.0.13 (2026-05-15) and the v0.0.14 attempt (2026-05-21), surfacing as 404 PUT errors on all three @simple-module-py/* publishes in run 26224490850. Rotating a new token just restarts the ~30-day clock.
  • Switch the publish-npm matrix to npm's OIDC Trusted Publishing (GA since Jul 2025), matching the PyPI side. Each job mints a short-lived id-token, exchanges it with npm, and publishes — no long-lived secret.
  • Pins npm to @latest because Node 24's bundled npm may sit below the 11.5.1 minimum for OIDC. Drops the manual .npmrc step and the NPM_TOKEN env on the publish step.

⚠️ Required before merging / next release run

Configure Trusted Publisher on each package's npm settings page — without this, the next release will fail because npm has no record that this repo is allowed to OIDC-publish:

For each: Trusted Publisher → GitHub Actions, with:

Field Value
Organization or user antosubash
Repository simple_module_python
Workflow filename release.yml
Environment npm

Test plan

  • Configure Trusted Publisher on all three packages (above).
  • Merge this PR.
  • Trigger release.yml with version=0.0.15 (PyPI side already has 0.0.14 from today's failed run, so reusing the version would fail those matrix entries even with fail-fast: false).
  • Verify all three publish-npm matrix jobs publish successfully and finalize commits the tag.
  • Cleanup in a follow-up: gh secret delete NPM_TOKEN and revoke the token at https://www.npmjs.com/settings/antosubash/tokens.

Fallback

If only some packages publish, this is likely npm/cli#8678 (open scoped-package OIDC bug). Revert this PR, rotate NPM_TOKEN to a classic automation token (no expiry, unlike granular tokens), and the original workflow works as-is.

The NPM_TOKEN secret (granular access token, 30-day default expiry)
expired between v0.0.13 and the v0.0.14 attempt, surfacing as 404 PUT
errors on all three @simple-module-py/* publishes. Rotating again just
restarts the clock.

Switch the publish-npm matrix to OIDC, matching the PyPI side: each job
mints a short-lived id-token, exchanges it with npm, and publishes
without a long-lived secret. Drops the manual .npmrc auth step and the
NPM_TOKEN env on the publish step, and pins npm to the latest CLI since
Node 24's bundled npm may lag behind the 11.5.1 minimum for OIDC.

Requires Trusted Publisher config on each package's npm settings page
(org=antosubash, repo=simple_module_python, workflow=release.yml,
environment=npm) before the next release run.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 21, 2026

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 927c9bf
Status: ✅  Deploy successful!
Preview URL: https://b845c389.simple-module-python.pages.dev
Branch Preview URL: https://fix-release.simple-module-python.pages.dev

View logs

- Drop `npm install -g npm@latest` — Node 24.15.0 already ships npm
  11.12.1 (well above the 11.5.1 floor for Trusted Publishing); the
  step was ~5-15s of waste per matrix job, and the comment claim that
  "Node 24's bundled npm may lag" was empirically wrong.
- Add `contents: read` to publish-npm's job-level permissions block.
  Job-level permissions replace (not merge with) workflow-level perms,
  so the previous block silently set `contents: none` — fine today,
  but a footgun for any future cache:/checkout: step.
- Mirror least-privilege on publish-pypi for symmetry: same OIDC scope,
  drops the inherited `contents: write` it never needed.
- Fix stale top-level comment that still claimed "npm uses NPM_TOKEN".
@antosubash
antosubash merged commit d5630bf into main May 21, 2026
12 checks passed
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