Skip to content

ci: run the release shell on every PR instead of on every tag - #44

Merged
stuffbucket merged 2 commits into
mainfrom
ci/test-release-shell
Sep 4, 2026
Merged

stuffbucket merged 2 commits into
mainfrom
ci/test-release-shell

Conversation

@stuffbucket

@stuffbucket stuffbucket commented Sep 4, 2026 •

Copy link
Copy Markdown
Owner

Closes #42.

Summary

Release verification logic moves out of release.yml into scripts/release/, and a fixture-driven self-test runs it in the normal PR gate. The goal is to make release shell testable before a tag is cut rather than only during a release.

Background

release.yml contained 522 lines of shell that executed for the first time during a real release. A single iteration costs a tag, a 20-40 minute signed build, Apple's notarization queue, and a manual approval. Two defects were found this way:

  • v0.5.0-rc.3: the builder produced and checksummed the zip but never uploaded it, because the workflow's upload allow-list omitted it.
  • v0.5.0-rc.4: all four assets were built, signed, notarized, stapled, and uploaded correctly, but the run failed on a debug line, echo "$ENTRIES" | head -5.

actionlint and shellcheck both ran against this code and reported nothing. Neither defect is detectable by static analysis; both are detectable by execution.

Changes

New scripts

Script Responsibility
contract.sh Parse .macos-builder/config, cross-check forge.config.ts, expand {tag} and {version}
verify-assets.sh Checksums, size floor, UDIF koly trailer, PKZip magic, Info.plist, stapled-ticket marker
prev-tag.sh Resolve the previously released tag
selftest.sh Drive the above against fixtures, asserting both success and failure paths

release.yml retains only orchestration: the job graph, gh calls, output wiring, and the asset wait loop. It drops from 522 to roughly 430 lines.

CI

selftest.sh and shellcheck run in the check job, before the install step. They are placed inside that job rather than in a separate one because build / typecheck / lint / test is the only check required by main's ruleset; a separate job would run without gating merges.

shellcheck coverage now includes scripts/verify-dmg.sh, which was 485 lines that no linter or test had previously exercised. It required no changes.

Contract resolution

The contract is now read from the tag via git show, while the scripts and workflow come from the checkout:

Source Read from Rationale
release.yml, scripts/release/ The dispatched branch A fix to release machinery can reach an already-cut tag
.macos-builder/config, forge.config.ts The tag The released contract is always the tag's own

On a tag push these are the same commit. On workflow_dispatch the checkout is a branch, and this split prevents building the tag's commit against main's contract. This is the code-side prerequisite for #42; see Follow-ups.

Previous-tag selection

The prior implementation was:

git tag --list 'v*' --sort=-creatordate | grep -vxF "$TAG" | head -1

This returns the newest tag that is not $TAG, which is a newer tag whenever an older tag is re-released. Against the current tag list, re-releasing v0.5.0-rc.3 would compare its bundle identity against v0.5.0-rc.5. The replacement takes the entry following $TAG in a newest-first listing, which is the previous release by construction. Covered by four test cases.

Verification

Self-test: 27 assertions, 0 failures, approximately 2 seconds. Identical results on macOS (bash 3.2) and on the Ubuntu runner.

Regression detection. Reintroducing either failed form causes the suite to fail:

Reintroduced Result
echo "$ENTRIES" | head -5 Exit 141, matching the rc.4 failure
printf … | grep -qxF … Reports a stapled app as unstapled

The second case is the more dangerous of the two: it does not crash, it inverts the verdict of the check that guards offline launch.

Real artifacts. verify-assets.sh was run against the released v0.5.0-rc.4 dmg and zip (320 MB): the computed sha256 matches what the release run reported, the UDIF trailer validates, and the zip's Maximal.app is confirmed stapled. Exit 0 in 0.83s, including the rewritten trailer read (dd at an offset, replacing tail -c 512 | head -c 4), which costs 0.13s of CPU on a 171 MB image.

shellcheck and actionlint are clean.

Correction to the rc.4 diagnosis

The commit message for #43 stated that the zip listing was "thousands of entries, far past the 64K pipe buffer, so the write cannot complete." This was incorrect.

The actual listing is 604 entries, 55,827 bytes, which is below a pipe's 64 KB capacity. The failure is a race rather than a size threshold: head closes the read end after five lines, and whether the writer has finished by then depends on scheduling. The Ubuntu runner lost the race; the same pipeline over the same artifact exits 0 on macOS.

This makes the original defect intermittent and platform-dependent. The zip fixture is therefore sized at 6,009 entries (353,196 bytes), roughly six times the real listing, so that a reintroduced pipeline fails deterministically on any machine. selftest.sh asserts the fixture remains large enough, and fails if it does not.

Follow-ups

This PR completes only the code half of #42. Dispatch-based recovery additionally requires a branch to be added to the release environment's deployment policy, which is a repository setting and not changed here.

Two releases were spent finding two bugs that no linter can catch:

  v0.5.0-rc.3  the builder built and checksummed the zip and never
               uploaded it; the upload list did not mention it.
  v0.5.0-rc.4  all four assets were built, signed, notarized, stapled
               and uploaded CORRECTLY, and the release still failed, on
               a debug `echo "$ENTRIES" | head -5`.

Neither bug is the point. The point is that release.yml held 522 lines
of release-critical shell that first executed during a real release,
where one iteration costs a tag, a 20-40 minute signed build, Apple's
notary queue and a human approval.

The assertions now live in scripts/release/, and selftest.sh drives
every one of them against fixtures in the ordinary PR gate: 27 checks,
seven seconds, no tag, no Mac, no credential. Reintroducing either
failed form makes it fail — `| head -5` at exit 141, `| grep -q` by
reporting a stapled app as unstapled.

What the fixture is for: the real rc.4 listing is 604 entries / 55,827
bytes, UNDER a pipe's 64K capacity. It broke the release anyway, because
the reader closing its end mid-write is a RACE — lost on the Ubuntu
runner, won on macOS, where the identical pipeline over the identical
artifact exits 0. The fixture is ~6x larger so the failure is
deterministic on any machine rather than intermittent on one.

Also fixed, found while extracting: the previous-tag lookup took the
newest tag that is not $TAG, which is a NEWER tag when an older one is
re-released. Against the real tag list, re-releasing rc.3 compared its
bundle identity against rc.5. It is now the entry after $TAG in a
newest-first listing, with tests.

The contract is now read from the TAG (`git show`) while the scripts
come from the CHECKOUT. On a tag push those are the same commit; on
workflow_dispatch the checkout is a branch, so a fix to the release
machinery reaches an already-cut tag while the contract released stays
the tag's own. That split is what makes the recovery path in #42 safe to
enable.

shellcheck now covers scripts/release/ and scripts/verify-dmg.sh, which
was 485 lines of unlinted, never-executed acceptance test. It was clean.

Verified against the real v0.5.0-rc.4 artifacts: same sha256 the release
run reported, valid UDIF, stapled app, exit 0 in 0.83s.
The gate went red on its first run, on three `A && B || C` argument
checks that shellcheck 0.9.0 flags as SC2015 and 0.11.0 does not. The
runner image ships 0.9.0; a maintainer's Mac has 0.11.0.

Both halves fixed. The checks become explicit `if` statements, which is
what they meant and what .macos-builder/build.sh already advocates for
exactly this shape. And the lint runs at --severity=warning with the
version echoed, so info-level findings — style opinions that move
between shellcheck releases — cannot turn the gate red on an image bump
that changed nothing in this repository. Warnings and above still fail;
the SC2046 this same lint caught earlier is a warning.
@stuffbucket
stuffbucket merged commit 34dd8b6 into main Sep 4, 2026
6 checks passed
@stuffbucket
stuffbucket deleted the ci/test-release-shell branch September 4, 2026 22:26
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.

release.yml: the documented dispatch recovery path cannot reach the builder

1 participant