ci: fix npm publish never firing after automated release tags#98
Open
dmchaledev wants to merge 1 commit into
Open
ci: fix npm publish never firing after automated release tags#98dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
auto-tag.yml pushes release tags using the default GITHUB_TOKEN. GitHub does not fire `push` events for refs pushed with GITHUB_TOKEN (to avoid workflow recursion), so publish.yml's `on: push: tags: v*` trigger has never actually fired for an automated tag. Verified against live state: npm has only ever published v1.0.1, while tags v1.0.2 and v1.0.3 exist on the remote and publish.yml's run history contains zero tag-push-triggered runs since the auto-tag workflow was introduced. Add a `workflow_run` trigger that fires when the "Auto Tag" workflow completes successfully (the same pattern auto-tag.yml already uses to chain off of CI), and resolve the version from the tag pointing at that commit when not triggered by a direct tag push.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
npm publishhas silently never run for any automated release. Verified against live state, not just the workflow YAML:npm view @hailbytes/security-headers versionsshows only1.0.1(published 2025-05-19) — that's the only version ever published.v1.0.2(→608b6f5) andv1.0.3(→b2143bb), both created byauto-tag.ymlon 2026-06-16.publish.yml's entire run history isworkflow_dispatchevents; its last run was 2026-05-29, three weeks beforev1.0.2/v1.0.3were tagged. It has never once run off a tag push.Root cause:
auto-tag.ymlpushes the release tag using the defaultsecrets.GITHUB_TOKEN(.github/workflows/auto-tag.yml:21,42). GitHub does not fire downstreampushevents for refs pushed with the defaultGITHUB_TOKEN(this is intentional, to prevent workflow-triggering recursion). Sopublish.yml'son: push: tags: 'v*'trigger never sees the tagauto-tag.ymlcreates, andnpm publishnever runs.Impact: every
npx @hailbytes/security-headers/npm installinvocation has been running1.0.1code for the last ~3 weeks (and indefinitely, until this is fixed), missing all subsequent grading-correctness fixes that landed inmain(CSPbase-uri/bare-scheme checks, HSTS revocation handling, referrer-policy/cross-origin scoring fixes, etc. — see #94 for the full list). This is a real, currently-live gap for anyone using the published package, not a cosmetic version mismatch.This is a more precise root cause than #94, which attributes the drift to
package.jsonnot being committed back after publish — that's a real secondary issue, but it's moot right now because publish isn't happening at all.Fix
Add a
workflow_runtrigger topublish.ymlthat fires when theAuto Tagworkflow completes successfully — the same chaining patternauto-tag.ymlalready uses off ofCI(workflow_run: workflows: ["CI"]). This event type isn't subject to theGITHUB_TOKENpush restriction, since it's keyed off the completion of the upstream workflow run itself, not off a ref push.github.event.workflow_run.head_sha(the exact commitauto-tag.ymltagged) when triggered this way, falling back togithub.shafor the existingpush/workflow_dispatchtriggers.v*tag pointing atHEADinstead of parsingGITHUB_REF.push: tags: 'v*'andworkflow_dispatchtriggers as-is, so a manually/PAT-pushed tag or a manual run still works exactly as before.Test plan
.github/workflows/publish.ymlYAML parses (python3 -c "import yaml; yaml.safe_load(open('.github/workflows/publish.yml'))")CIonmain→Auto Tagcreatesv1.0.4→ this workflow'sworkflow_runtrigger fires →npm view @hailbytes/security-headers versionshows1.0.4shortly after (needsNPM_PUBLISH_TOKENto be valid; I can't trigger this from a PR branch)workflow_dispatchand directpush: tagspaths still behave as before (unchanged logic, guarded by the sameif [[ "$GITHUB_REF" == refs/tags/v* ]]branch)Related: #94 (stale
package.json/CHANGELOG.md— becomes actionable once publishing actually resumes).Generated by Claude Code