feat: push-to-publish npm automation - #2
Conversation
On push to main, if package.json's version is not on the registry: npm ci + jest + npm publish --provenance. Version bumps ship inside feature PRs, so a merged PR publishes with no human step. Fails loudly (with setup instructions) when a publish is due but NPM_TOKEN is missing; exact-version registry check makes re-runs and no-bump pushes no-ops. Tracking: verticalint DEV-5890. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
AI review (advisory) — cycle 1
SummaryThe core mechanism is verified sound — but the review found one real blocker ( Empirical verification (run against the live registry)
Findingsblocker: nit (hardening): nit: this repo has no PR-time CI ( Verdict (3779765): REQUEST_CHANGESThe dispatch-ref blocker must land before merge; fixes queued for cycle 2. |
Cycle-1 review fixes (PR #2): - blocker: workflow_dispatch could run on any branch and publish unmerged code — job now requires github.ref == refs/heads/main. - hardening: NAME/LOCAL from package.json are validated with bash [[ =~ ]] whole-string anchors before shell/GITHUB_OUTPUT interpolation (grep -q matches per-line and would let a newline-injected value through — caught while testing the first version of this very fix). - comment: registry-check transient failures are fail-safe (republish of an existing version is rejected by the registry). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
AI review (advisory) — cycle 2
Per-finding verification (cycle 1)
Fresh-eyes pass on the fix commit
Verdict (8a45f01): APPROVEAll cycle-1 findings fixed or explicitly dispositioned. GitHub rejects author self-approval, so this closes at handoff: ready for you to merge once |
Closes the cycle-1 review nit (no PR-time CI) and gives the merge gate a real head pipeline to check — the gate correctly refused to merge a PR with no pipeline at all. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
AI review (advisory) — cycle 3
What changed since cycle 2
Verification
Verdict (d5eb9cb): APPROVEAll findings across all cycles now implemented (dispatch-ref guard, whole-string input validation, PR-time CI). Merge when the |
PR #2's first CI run surfaced that GitHub runners lack ripgrep and the grep fallback in src/search.js silently matches nothing (POSIX ERE vs the PCRE-style color patterns) — 3 of 8 search tests fail through it, reproducible locally by hiding rg from PATH. CI (both ci.yml and the publish workflow's test step) now installs ripgrep so it exercises the tool's primary path; the fallback fix is tracked in #3. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
AI review (advisory) — cycle 4
What changed since cycle 3
Verification
Verdict (9a6db38): APPROVEConverged on a green head. Merge → the |
What
Push-to-publish automation (
.github/workflows/publish.yml): on every push tomain, ifpackage.json's version is not yet on the npm registry, CI runsnpm ci+jestandnpm publish --provenance --access public. The version bump ships inside the feature PR, so a merged PR publishes with zero further human steps. Also adds a## ReleasingREADME section.Design points:
npm view <name>@<version>) — re-runs and no-bump pushes are clean no-ops, and a version revert can't republish over an existing release.NPM_TOKENis missing — the error message carries the setup command.workflow_dispatchfor idempotent catch-up runs (e.g. right after adding the secret).--provenanceattaches a build attestation linking the tarball to this workflow run.One-time setup (repo owner)
hardcode-replaceris best).gh secret set NPM_TOKEN --repo ytspar/hardcode-replacer(paste the token).mainwill see 2.3.0 ≠ registry (2.2.0) and perform the pending v2.3.0 publish as its first live action.Why
v2.3.0 has been merged but unpublished since PR #1 — no machine here holds npm credentials, and manual publishing is the exact human-intervention step being eliminated (tracking: verticalint DEV-5890). This repo is the ship-use-refine first instance; the same workflow rolls out to the other npm-published ytspar repos next.