Skip to content

fix(ci): rewrite release workflow with OIDC trusted publishing - #202

Closed
cs-raj wants to merge 4 commits into
mainfrom
fix/autotag-github-token
Closed

fix(ci): rewrite release workflow with OIDC trusted publishing#202
cs-raj wants to merge 4 commits into
mainfrom
fix/autotag-github-token

Conversation

@cs-raj

@cs-raj cs-raj commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Problem

The release workflow was broken in two ways:

  1. Klemensas/action-autotag@1.2.3 always failed with 404 — the action hardcodes head: 'master' when generating a changelog via the GitHub compare API, but this repo uses main. Every push to main hit a 404 and skipped all downstream publish steps silently.

  2. Token-based publishing — used long-lived TYPES_GENERATOR_AUTOMATION PAT for npmjs.com and PKG_TOKEN PAT 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-npm job (npmjs.com)

  • Dropped Klemensas/action-autotag@1.2.3 entirely
  • Dropped JS-DevTools/npm-publish@v2.2.0 and TYPES_GENERATOR_AUTOMATION token
  • Added id-token: write permission for OIDC
  • npm publish --access public with npm_config_registry env var — OIDC trusted publishing handles auth automatically, provenance generated by default
  • npm install -g npm@latest — npm ≥ 11.5.1 required for OIDC
  • No registry-url on setup-node — avoids empty _authToken entry in .npmrc that can block OIDC detection

publish-github job (GitHub Packages)

  • Uses registry-url: https://npm.pkg.github.com/ on a second setup-node call (after npm ci) so devDependency install still resolves from npmjs.com
  • NODE_AUTH_TOKEN: ${{ github.token }} — short-lived token, no PAT needed
  • Node 22.x → 24

Test plan

  • Create a GitHub Release and confirm publish-npm completes without ENEEDAUTH
  • Verify provenance attestation appears on the published version at npmjs.com
  • Confirm publish-github publishes to GitHub Packages successfully

🤖 Generated with Claude Code

…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>
@cs-raj
cs-raj requested a review from a team as a code owner September 2, 2026 08:59
@snyk-io

snyk-io Bot commented Sep 2, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 2 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ 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:

  • Critical without fixes: 0
  • High without fixes: 0
  • Medium without fixes: 2
  • Low without fixes: 0

✅ 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>
@cs-raj
cs-raj requested a review from a team as a code owner September 3, 2026 05:44
cs-raj and others added 2 commits September 3, 2026 11:22
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>
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 0 25 ✅ Passed
🟡 Medium Severity 0 2 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ 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:

  • Critical without fixes: 0
  • High without fixes: 0
  • Medium without fixes: 2
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

@cs-raj cs-raj changed the title fix(ci): pass GITHUB_TOKEN as env var to action-autotag and grant contents:write fix(ci): rewrite release workflow with OIDC trusted publishing Sep 3, 2026
@cs-raj

cs-raj commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Closing — the workflow changes from this PR were already merged directly into main (commit cb1417d). Lockfile sync tracked in #203.

@cs-raj cs-raj closed this Sep 3, 2026
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.

3 participants