0172: Releases run end to end in CI¶
- Implementation partial
Context and Problem Statement¶
0.9.58 needed an operator at every Apple step: a debug entitlement failed publish after the tag existed, every
candidate run flaked once, a failed and unpublished tag was replaced by hand through local recovery worktrees, the
macos-developer-id environment waited for a person to approve, notarization outlived the job's 20 minute wait
(submission 5bc7e4c9-…, nothing published), the Electron app shipped ad-hoc sealed and not notarized, and the iOS
build reached TestFlight only through sm release ios on the Mini. The owner decided (28 Nov 2026) that publishing the
macOS, Electron and iOS apps must be delightful and easy, at best done in CI with little help from sm. How does a
merged release PR become a published, accepted, Latest release with no operator step?
Decision Drivers¶
- No operator step between the release-PR merge and Latest;
smstarts and reports, it never drives a stage. - Every automatic retry is bounded and auditable: it names the known flake, the failed run or the submission it resumes.
- Nothing published is ever replaced; the tested bytes stay the bytes promoted or signed.
- Secrets reach only jobs that checked the release identity first.
Considered Options¶
- CI chain with bounded self-healing and policy-approved signing (chosen)
- Keep
smas the driver and automate its local steps: the Mini stays a single point of failure and needs its local keys, recovery worktrees and the owner's click. - Required reviewer approved by a token in the same run: keeps the click's form but not its meaning; one more owner token with deployment rights.
Decision Outcome¶
Chosen option: CI chain with bounded self-healing and policy-approved signing. After the release PR merges:
- Tag (
release-tag.yml).scripts/release_retag.pydecides from GitHub facts:createa missing tag;noopfor a published one;republisha tag on this commit whose Publish failed and that has no publication;replacea tag on an older commit only when every publication surface is absent (no GitHub release, draft included; PyPI has no such version; the plugins repository has noapp-vX.Y.Zwhen readable, and composition needs a published Core wheel), the latest Release tag run of the old commit concludedfailurewith none in progress, and the old commit is an ancestor of the new main commit. The replacement tag's annotation and a run artifact record the original tag object, its commit and the failed run. Anything else isrefuse. After every Publish, a republish included, Release tag dispatches the tail (release-tail.yml); a failed Publish resumes by rerunning its failed jobs (the run keeps the merge commit asGITHUB_SHA, which the producer manifest and the signing admission bind) or, once main moved on, by a recovery release commit that takes thereplacepath. A dispatch input that publishes an old tag from main's tip is not offered: it would need the producer, PyPI and installer provenance checks to accept a caller commit other than the tagged one. - Candidate rerun (
release-rerun.yml,scripts/release_rerun.py). An infrastructure failure (no hosted runner took the job, or only a set up, checkout or artifact step failed) is rerun on any branch, on attempts 1 and 2, and GitHub reads answered with a server error are tried again. When the release PR's CI run fails on attempt 1, CI reruns its failed jobs once, only when every failed job (theCI OKaggregate aside) matches an in-date entry of.github/known-flakes.tomlby job name and log signature, and every failing test node id in the log's pytest summary is listed in the entry'stests(bead id,added,untilat most 7 days later, as sm's KNOWN registry; sm reads this one registry). Attempt 2 leaves attempt 3 of the publisher'sMAX_ATTEMPTS = 3(scripts/release_candidate.py, #1007) for a person; an UNKNOWN failure is never rerun automatically. Against a publisher withoutMAX_ATTEMPTS(no rerun evidence) nothing is rerun. The signing admission derives the candidate run from the merged PR's head (its one completed CI run onrelease/vX.Y.Z) instead of the operator-setHEINZEL_MAC_CANDIDATE_RUN, which stays an override. - Publish (
publish.yml). The Swift app and the Electron app are both signed with the Developer ID identity, hardened runtime and explicit entitlements, notarized with the notary key, stapled and checked withcodesign --verify --deep --strictandspctl --assessafter extraction. Electron's helpers get onlycom.apple.security.cs.allow-jit(V8 maps JIT pages under the hardened runtime,@electron/osx-sign's renderer and GPU default); the main app addsdevice.audio-input(the microphone visualizer),device.usbanddevice.bluetooth(devices a site may use in the mini browser). It loads no plugin and no unsigned native code, so it needs neitherallow-unsigned-executable-memorynordisable-library-validation(osx-sign's plugin-helper defaults). Notarization is resumable (apple/scripts/notary.py): the submission id is recorded before any wait, a wait that outlives its budget (45 minutes) exits 75 and keeps the signed bytes and the record as an artifact, and a resume job waits for that same submission (90 minutes, rerunnable as failed jobs), keyed on the submission id and the zip's SHA-256, instead of re-signing. Publish binds the notarized Electron archive in the release manifest. Then the GitHub release, then PyPI. (A Linux poller of the Notary API and signing after notarization are later steps.) - Tail (
release-tail.yml). PyPI, Standard compose (dispatched with the exact version and Core wheel; a missingRELEASE_TOKENor a failed dispatch fails the tail instead of waiting for the plugins' schedule), official acceptance on both OSes, verdict, marker, Latest. Once acceptance passed it dispatches Release iOS (release-ios.yml,apple/scripts/testflight-release,scripts/release_testflight.py) on a macOS runner: one build per version, archive with the tag'sExportOptions-testflight.plistsigning,widget_configuration.py archivecheck, upload, processing wait (30 minutes), internal-group assignment, What to Test from the release notes; an existing build of the version is confirmed, never uploaded twice, so a dispatch again resumes. Noneedsedge leads from it to the verdict: Apple never delays or withholds an accepted release. A failed tail dispatches a fresh run of itself, up to 3 runs per version; a rerun of failed jobs cannot count. - Signing approval by policy.
macos-developer-idandapp-store-connecthave no required reviewer; their deployment policy admits only the protectedmainbranch. Before secrets are used, each signing job runsscripts/release_signing_policy.py: core repository, protectedrefs/heads/main, callerrelease-tag.yml@refs/heads/main(orrelease-ios.yml@refs/heads/mainfor TestFlight), eventpushorworkflow_dispatch, run attempt at most 3, and the promote job's admitted commit equal toGITHUB_SHA(for TestFlight: the tag's commit, bound to main's history).v*tags are never admitted to an environment. A unit test fails when any other job namesmacos-developer-idorapp-store-connect. - Hold and ledger. Every job that writes a release surface first runs
scripts/release_control.py gate STAGE, which stops (exit 78) while the repository variableRELEASE_HOLDnames the stage orall; clearing it and rerunning the job resumes. Stages post commit statusesrelease/<stage>on the release commit (the notary submission id while pending);scripts/release_status.py X.Y.Zprints them beside the primary facts (tag, release and manifest, Latest, acceptance marker, PyPI). Statuses are display only; no irreversible step trusts them. A held gate postsrelease/<stage>"held";resumewithout a stage resumes every held stage, and a heldtagstage is found through the merged release commit before any tag exists. The tail holds before acceptance (jobgate-acceptance), and the verdict and GitHub-release gates wait for a hold to clear (reading the variable or Release control'srelease/holdmirror) instead of failing, so a hold never spends first-attempt acceptance or a notarization. The tail postsrelease/pypi,compose,acceptanceandverdictand finishesrelease/tail; the verdict attachesrelease-record.json(status history, control runs, stage table).abortalso cancels the version's running Release tag, tail and iOS runs. Release control (release-control.yml) is the one operator surface: status, hold, resume, retry (rerun a failed Release tag run's jobs below its last attempt, or dispatch the tail or iOS again), waive (only iOS and a candidate's third attempt), abort (hold all) and replace-tag (dispatch Release tag on a recovery release commit). Onlyvars.RELEASE_OPERATORSact; waive, abort and replace-tag need a bead and a reason. Publish uploads every asset to a draft, checks it and only then makes the release public; a draft a failed Publish left on the same commit is deleted and published again.
What sm keeps: sm release VERSION starts the release (opens and merges the release PR through the queue), sm
release status and sm why VERSION render release_status.py, a hold is the variable RELEASE_HOLD, and sm
reports alarms and verifies the Mini. What it no longer does: approve the signing environment, rerun a candidate with a waiver, delete or recreate a
tag, run recovery-pr or recovery-merge worktrees, or upload iOS builds from the Mini (sm release ios stays a manual
fallback until the CI job has published one release).
Owner setup (GitHub settings and secrets; CI never changes them):
- Environment
macos-developer-id: remove required reviewers and the wait timer; deployment branches and tags: selected, branchmainonly. Keep its secretsHEINZEL_MAC_CERTIFICATE_B64,HEINZEL_MAC_CERTIFICATE_PASSWORD,HEINZEL_MAC_NOTARY_KEY_B64and variablesHEINZEL_MAC_SIGNING_TEAM,HEINZEL_MAC_NOTARY_KEY_ID,HEINZEL_MAC_NOTARY_ISSUER. The Electron job uses the same ones. - New environment
app-store-connect, branchmainonly, no reviewer, secretsASC_KEY_P8_B64(theheinzel-miniAPI key, App Manager role; a separate Developer-role key for notarization),HEINZEL_IOS_CERTIFICATE_B64andHEINZEL_IOS_CERTIFICATE_PASSWORD(Apple Distribution.p12),HEINZEL_IOS_PROFILE_B64("Heinzel iOS App Store Mini") andHEINZEL_IOS_WIDGETS_PROFILE_B64("Heinzel iOS Widgets App Store Mini"); variablesASC_KEY_ID,ASC_ISSUER_ID. Repository variableHEINZEL_IOS_TESTFLIGHT=trueturns the job on. Repository variablesRELEASE_HOLD(empty) andRELEASE_OPERATORS(your login). DeleteHEINZEL_MAC_CANDIDATE_RUNafter the first release that derived its candidate. RELEASE_TOKEN(fine-grained): Actions write onheinzel-pluginsfor the compose dispatch, Variables write onheinzelfor hold and resume.- Confirm the
pypitrusted publisher ispypi.ymlwith environmentpypi. - Tag rulesets on
v*, if any: allow GitHub Actions to delete and create release tags (the replacement path). - Actions settings: workflows may rerun jobs with
GITHUB_TOKEN(actions: write, the default for this repository).
Consequences¶
- Good: a release needs no click after the merge; the 0.9.58 failures each have a bounded automatic path.
- Good: Electron users get a notarized app; Gatekeeper accepts both Mac apps.
- Bad: signing secrets are available to any job on protected
mainthat names the environment; review of workflow changes on main and the policy step replace the click. - Bad: the known-flake registry must be kept current in Core; an expired entry turns a flake back into a stop.
Confirmation¶
Unit tests drive every decision of release_retag.py, release_rerun.py, release_signing_policy.py,
release_control.py, release_status.py, release_testflight.py, notary.py and sign-electron.py with fake
gh, App Store Connect, notarytool, codesign and spctl; a workflow test holds the environment allowlist, the
hold gate before every write and the missing iOS-to-verdict edge; actionlint and zizmor check the workflows. The first hosted release proves the Apple steps.
More Information¶
Lessons: the 0.9.58 retrospective (lessons 1 to 12). The hosted chain (release-chain.yml) still keeps release
writes off until the protected freeze and queue integration land; these jobs run on the Release tag, Publish, Release
tail and Release iOS path, which needs no chain write. Open: the chain's own candidate step still requires a first
attempt and must take the rerun evidence of release_candidate.py (#1007, on main, not yet on this line); a rehearsal run
with fault injection, a plugins-compat compose of the candidate wheel and a Developer-ID-shaped entitlement build in
the candidate.