Repository navigation
fix(npm): attach the offline bundle on tag dispatches - #875
Conversation
The upload step required event_name == 'push' AND a tag ref, but stable releases reach this workflow as a workflow_dispatch on the tag (bot-pushed tags never trigger workflows), so the step was silently skipped: v2.1.16 and v2.1.17 shipped without codex-proxy-npm.zip and the README's /releases/latest/download link 404s. Key the condition off the ref alone.
|
Fork verification before opening this (per my own workflow), all on the exact commit 1. The failing path itself — Tagged the fix commit and dispatched
Test tag/release deleted afterwards. 2. Full CI on the fix — fork PR nieyuanhong/codex-proxy#16
3. Local
|
SsuJojo
left a comment
There was a problem hiding this comment.
Review: LGTM (approve) — one note about the backfill claim
Root cause and fix both check out:
- Root cause verified: runs 38362508934 (v2.1.16) and 38592736055 (v2.1.17) are
workflow_dispatchwithhead_branch=v2.1.16/17, and theAttach offline npm bundle to the releasestep isskippedin both.v2.1.16/v2.1.17releases indeed have nocodex-proxy-npm.zip. - Dispatch path confirmed:
bump-electron.ymltags and then runsgh workflow run npm-publish.yml --ref "$NEW_TAG"→github.ref = refs/tags/<tag>, sostartsWith(github.ref, 'refs/tags/')is true. Real tag pushes are still covered, PR (refs/pull/...) and branch dispatches correctly skip. - Idempotency:
gh release upload --clobber+ 8×15s retry loop handles both re-runs and the race withrelease.yml'snotesjob creating the release first. No asset-name collision with the release workflow. - Permissions:
publish-githubalready hascontents: writeand only differs in whether the step runs; no new privilege. - Verified your fork repro: run 38838067414 (
workflow_dispatch,head_branch=v2.1.16-npmfix) shows the attach stepsuccess.
⚠️ Correction to "Note on existing releases"
unless this workflow is dispatched again on those tag refs after the fix lands
This won't work: workflow_dispatch --ref v2.1.16 loads the workflow YAML as committed at that tag, which still contains the old event_name == 'push' condition — the step stays skipped. Backfilling v2.1.16/v2.1.17 needs one of:
- Download the retained
npm-tarballsartifact from those old runs (v2.1.16's is available until 2026-10-20), rebuild the zip withscripts/npm/offline-install.mjs, andgh release upload v2.1.16 codex-proxy-npm.zip; - or a temporary workflow on a branch (using
inputs.tag) that uploads to the given tag.
Worth correcting the PR note (and/or adding a short backfill note to the changelog) so nobody re-dispatches and concludes it's unfixable.
Minor / non-blocking
- A fork that dispatches on a tag without a GitHub Release now fails the job after ~2 min of retries instead of skipping. If that matters, gate with
github.repository == 'icebear0828/codex-proxy'; otherwise fine. - For consistency with the
Resolve package versionstep in the same file,github.ref_type == 'tag'reads a bit clearer thanstartsWith(github.ref, 'refs/tags/')— functionally equivalent.
Approving; nothing here blocks the merge.
Summary
The offline bundle
codex-proxy-npm.ziphas never been attached to a release: the upload step's condition requiredgithub.event_name == 'push', but stable releases reach this workflow as aworkflow_dispatch --ref <tag>(bot-pushed tags don't fire downstream workflows), so the step was silently skipped every time. Fix: key the condition off the ref alone.Impact
Since #872 made this bundle the recommended no-auth install path, the documented command currently fails for every reader:
Evidence on the released tags:
Attach offline npm bundleskippedskippedBoth runs are
workflow_dispatchon the tag ref, soevent_name == 'push'was never true.Fix
This covers both ways the workflow reaches a tag (real tag push, and the stable-release dispatch), and
GITHUB_REF_NAMEstill resolves to the tag name forgh release upload.Verification
Reproduced through the exact path that was failing — a fork tag dispatched as
workflow_dispatch --ref <tag>:npm-publishwith--ref v2.1.16-npmfix;Attach offline npm bundle to the release→ success (previouslyskipped);codex-proxy-npm.zip(12.27 MB) attached to that release and downloaded anonymously (HTTP 200, 12,868,796 bytes).The temporary test tag/release were deleted afterwards.
Local:
npx vitest run tests/unit/npm/npm-package.test.ts tests/unit/ci/package-boundary.test.ts→ 22 passed; all workflow YAML parses.Note on existing releases
A skipped step cannot be recovered by "re-run failed jobs", and re-dispatching
npm-publish.yml --ref v2.1.16does not help either:workflow_dispatchloads the workflow file as committed at that tag, which still contains the old condition, so the step stays skipped.To backfill v2.1.16 / v2.1.17 (v2.1.16's
npm-tarballsartifact is retained until 2026-10-20):npm-tarballsartifact from the old run;*.tgzfiles plusscripts/npm/offline-install.mjs(asinstall.mjs) into a directory andzip -r codex-proxy-npm.zip .;gh release upload v2.1.16 codex-proxy-npm.zip(andv2.1.17).Alternatively, run a temporary branch workflow that takes the tag as an
inputs.tagand uploads the bundle for that tag.Changes
.github/workflows/npm-publish.yml— step condition + comment.CHANGELOG.md—[Unreleased] / ### Fixedentry.