ci: harden publish workflow against non-fast-forward bump push
Merged
SW
4mo ago+10+10+01234567890123456789-4-4-0123456789
Why
The Publish to npm workflow failed twice on cli#24's release:
- First run: bad
NPM_TOKEN→E404atpnpm publish(token since fixed). - Re-run: failed before publish, at the version-bump push —
! [rejected] main -> main (fetch first). The re-run checked out the
original pre-bump SHA, andgit pushwas non-fast-forward because the first
run had already pushed the0.1.14bump tomain.
Net: main is at 0.1.14 but npm is still 0.1.13 (never published).
Fix
checkoutwithref: main+fetch-depth: 0— the job always operates on the latestmaintip (re-runs stop using a stale SHA) with full history for the rebase.git pull --rebase origin mainbefore the bump — race safety net so the push is always fast-forward.git push origin HEAD:main(explicit) + capture the new version straight fromnpm versionoutput (removes thenode -p require()).workflow_dispatchtrigger so a publish can be re-kicked from the Actions UI without pushing a commit.
Effect on merge
Merging this is itself a push to main → triggers a fresh run from the current tip (0.1.14) → bumps to 0.1.15 → publishes with the (now valid) token. After it goes green, npm view @recoupable/cli version should show 0.1.15 with the emails command rename.
Gate reminder (chat#1815): don't promote api#711 to prod (api#715) until this publishes.
🤖 Generated with Claude Code
Summary by cubic
Hardened the npm publish workflow so the version-bump push is always fast-forward, even on re-runs or races. The job now operates from the latest main and supports manual runs.
-
Bug Fixes
- Checkout with
ref: mainandfetch-depth: 0to always use the latestmainwith full history. - Rebase before bumping:
git pull --rebase origin mainto keep the push fast-forward. - Push explicitly with
git push origin HEAD:main. - Read the new version from
npm versionoutput (drops thenode -p require()).
- Checkout with
-
New Features
- Add
workflow_dispatchto trigger a publish from the Actions UI without a new commit.
- Add