fix(ci): rewrite release workflow with OIDC trusted publishing - #202
fix(ci): rewrite release workflow with OIDC trusted publishing#202cs-raj wants to merge 4 commits into
Conversation
…tents:write
Klemensas/action-autotag@1.2.3 no longer accepts GITHUB_TOKEN as a
with: input — it must be supplied via env:. Without a valid token the
action's GitHub API calls returned 404 ("Not Found"), aborting the tag
and all downstream release steps.
Also bumps the release job's permissions from contents:read to
contents:write, which is required for the autotag action to push a new
git tag.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
✅ BUILD PASSED - All security checks passed |
- Switch trigger from push:main to release:published — publishing is now gated on a deliberate GitHub Release rather than every push - Drop Klemensas/action-autotag@1.2.3 — broken action that hardcoded 'master' as the compare head, causing 404 failures; tags are now created by the person publishing the GitHub Release - Drop JS-DevTools/npm-publish + TYPES_GENERATOR_AUTOMATION token — replaced with plain 'npm publish --access public' which uses the OIDC token issued via id-token:write (trusted publishing); provenance is generated automatically, no --provenance flag needed - Add id-token:write to release job permissions for OIDC - Add registry-url to setup-node so .npmrc is written correctly - Upgrade Node 22.x → 24 (minimum required for npm trusted publishing) - npm install → npm ci for deterministic installs - Add 'npm install -g npm@latest' (requires npm ≥ 11.5.1 for OIDC) - Remove fetch-depth:0 (only needed for autotag history traversal) - Remove 'Display dirs' debug step - Keep GitHub Packages publish with PKG_TOKEN (separate registry, trusted publishing only applies to registry.npmjs.org) - Drop gh release create — release already exists when trigger fires Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
setup-node with registry-url writes _authToken=${NODE_AUTH_TOKEN} to
.npmrc; when NODE_AUTH_TOKEN is unset that entry is an empty string
which can cause ENEEDAUTH before npm's OIDC detection kicks in.
Remove registry-url from the setup-node step and pass the registry
directly as npm_config_registry env var on the publish step only —
npm reads this without touching .npmrc auth config, leaving OIDC
detection unobstructed.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main restructured release.yml into two clean separate jobs (publish-npm, publish-github). Kept that structure and applied our one fix: removed registry-url from publish-npm's setup-node to avoid empty _authToken in .npmrc, passing npm_config_registry as an env var on the publish step instead so OIDC detection is unobstructed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
✅ BUILD PASSED - All security checks passed |
Problem
The release workflow was broken in two ways:
Klemensas/action-autotag@1.2.3always failed with 404 — the action hardcodeshead: 'master'when generating a changelog via the GitHub compare API, but this repo usesmain. Every push tomainhit a 404 and skipped all downstream publish steps silently.Token-based publishing — used long-lived
TYPES_GENERATOR_AUTOMATIONPAT for npmjs.com andPKG_TOKENPAT for GitHub Packages. Trusted publishing was already configured on npmjs.com but the workflow wasn't using it.Changes
Trigger
push: branches: [main]→on: release: types: [published]Publishing is now gated on a deliberate GitHub Release. No more auto-publish on every push.
publish-npmjob (npmjs.com)Klemensas/action-autotag@1.2.3entirelyJS-DevTools/npm-publish@v2.2.0andTYPES_GENERATOR_AUTOMATIONtokenid-token: writepermission for OIDCnpm publish --access publicwithnpm_config_registryenv var — OIDC trusted publishing handles auth automatically, provenance generated by defaultnpm install -g npm@latest— npm ≥ 11.5.1 required for OIDCregistry-urlon setup-node — avoids empty_authTokenentry in.npmrcthat can block OIDC detectionpublish-githubjob (GitHub Packages)registry-url: https://npm.pkg.github.com/on a second setup-node call (afternpm ci) so devDependency install still resolves from npmjs.comNODE_AUTH_TOKEN: ${{ github.token }}— short-lived token, no PAT neededTest plan
publish-npmcompletes without ENEEDAUTHpublish-githubpublishes to GitHub Packages successfully🤖 Generated with Claude Code