Skip to content

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; sm starts 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 sm as 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:

  1. Tag (release-tag.yml). scripts/release_retag.py decides from GitHub facts: create a missing tag; noop for a published one; republish a tag on this commit whose Publish failed and that has no publication; replace a 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 no app-vX.Y.Z when readable, and composition needs a published Core wheel), the latest Release tag run of the old commit concluded failure with 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 is refuse. 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 as GITHUB_SHA, which the producer manifest and the signing admission bind) or, once main moved on, by a recovery release commit that takes the replace path. 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.
  2. 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 (the CI OK aggregate aside) matches an in-date entry of .github/known-flakes.toml by job name and log signature, and every failing test node id in the log's pytest summary is listed in the entry's tests (bead id, added, until at most 7 days later, as sm's KNOWN registry; sm reads this one registry). Attempt 2 leaves attempt 3 of the publisher's MAX_ATTEMPTS = 3 (scripts/release_candidate.py, #1007) for a person; an UNKNOWN failure is never rerun automatically. Against a publisher without MAX_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 on release/vX.Y.Z) instead of the operator-set HEINZEL_MAC_CANDIDATE_RUN, which stays an override.
  3. 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 with codesign --verify --deep --strict and spctl --assess after extraction. Electron's helpers get only com.apple.security.cs.allow-jit (V8 maps JIT pages under the hardened runtime, @electron/osx-sign's renderer and GPU default); the main app adds device.audio-input (the microphone visualizer), device.usb and device.bluetooth (devices a site may use in the mini browser). It loads no plugin and no unsigned native code, so it needs neither allow-unsigned-executable-memory nor disable-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.)
  4. Tail (release-tail.yml). PyPI, Standard compose (dispatched with the exact version and Core wheel; a missing RELEASE_TOKEN or 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's ExportOptions-testflight.plist signing, widget_configuration.py archive check, 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. No needs edge 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.
  5. Signing approval by policy. macos-developer-id and app-store-connect have no required reviewer; their deployment policy admits only the protected main branch. Before secrets are used, each signing job runs scripts/release_signing_policy.py: core repository, protected refs/heads/main, caller release-tag.yml@refs/heads/main (or release-ios.yml@refs/heads/main for TestFlight), event push or workflow_dispatch, run attempt at most 3, and the promote job's admitted commit equal to GITHUB_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 names macos-developer-id or app-store-connect.
  6. 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 variable RELEASE_HOLD names the stage or all; clearing it and rerunning the job resumes. Stages post commit statuses release/<stage> on the release commit (the notary submission id while pending); scripts/release_status.py X.Y.Z prints 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 posts release/<stage> "held"; resume without a stage resumes every held stage, and a held tag stage is found through the merged release commit before any tag exists. The tail holds before acceptance (job gate-acceptance), and the verdict and GitHub-release gates wait for a hold to clear (reading the variable or Release control's release/hold mirror) instead of failing, so a hold never spends first-attempt acceptance or a notarization. The tail posts release/pypi, compose, acceptance and verdict and finishes release/tail; the verdict attaches release-record.json (status history, control runs, stage table). abort also 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). Only vars.RELEASE_OPERATORS act; 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, branch main only. Keep its secrets HEINZEL_MAC_CERTIFICATE_B64, HEINZEL_MAC_CERTIFICATE_PASSWORD, HEINZEL_MAC_NOTARY_KEY_B64 and variables HEINZEL_MAC_SIGNING_TEAM, HEINZEL_MAC_NOTARY_KEY_ID, HEINZEL_MAC_NOTARY_ISSUER. The Electron job uses the same ones.
  • New environment app-store-connect, branch main only, no reviewer, secrets ASC_KEY_P8_B64 (the heinzel-mini API key, App Manager role; a separate Developer-role key for notarization), HEINZEL_IOS_CERTIFICATE_B64 and HEINZEL_IOS_CERTIFICATE_PASSWORD (Apple Distribution .p12), HEINZEL_IOS_PROFILE_B64 ("Heinzel iOS App Store Mini") and HEINZEL_IOS_WIDGETS_PROFILE_B64 ("Heinzel iOS Widgets App Store Mini"); variables ASC_KEY_ID, ASC_ISSUER_ID. Repository variable HEINZEL_IOS_TESTFLIGHT=true turns the job on. Repository variables RELEASE_HOLD (empty) and RELEASE_OPERATORS (your login). Delete HEINZEL_MAC_CANDIDATE_RUN after the first release that derived its candidate.
  • RELEASE_TOKEN (fine-grained): Actions write on heinzel-plugins for the compose dispatch, Variables write on heinzel for hold and resume.
  • Confirm the pypi trusted publisher is pypi.yml with environment pypi.
  • 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 main that 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.