Skip to content

feat(release): build signed, notarized macOS DMGs from a tag - #30

Merged
stuffbucket merged 2 commits into
mainfrom
feat/signed-macos-release
Sep 1, 2026
Merged

stuffbucket merged 2 commits into
mainfrom
feat/signed-macos-release

Conversation

@stuffbucket

Copy link
Copy Markdown
Owner

Restores the client half of the stuffbucket/macos-builder contract, adapted to this repo's pnpm/turbo monorepo layout. Nothing in macos-builder is modified.

What lands

File Role
.macos-builder/config What to build, and the single owner of the asset name
.macos-builder/build.sh Builds and inside-out signs only the .app
.github/workflows/release.yml tag → draft → dispatch → wait → verify
scripts/verify-dmg.sh Gatekeeper acceptance test
RELEASING.md Owns the process; AGENTS.md owns the rules

Design notes worth reviewing

  • pnpm on the builder. The builder supplies Node 24 + npm + Bun and no pnpm; adding it there would couple every other client repo to this one's toolchain. build.sh reads packageManager, installs that exact version with npm install --prefix into scratch from outside the checkout, then asserts the version. Not corepack — it is unbundled from Node 25.
  • Turbo is bypassed for packaging. The root package script is turbo run package, whose task declares outputs: ["out/**", ".vite/**"], so a cache hit could restore a bundle the release never built. Forge is invoked directly with a pinned --arch.
  • No pnpm run anywhere in the producer. Under this workspace it re-resolves and rewrites rotating ms-feed-N hosts into the lockfile before the script body runs (pnpm run re-resolves the lockfile, poisoning the Docker test context #26), which would poison the lockfile strip-lockfile-hosts.mjs had just repaired.
  • Signing is asserted locally. codesign -dvv must show Authority=Developer ID Application and flags=…runtime, and must not show Signature=adhoc. Without this, a bad signature surfaces as an opaque Apple rejection minutes later with no local evidence.
  • The workflow never publishes. It ends with a filled, verified draft. gh release edit --draft=false stays a deliberate manual act after the acceptance test.
  • dispatch holds permissions: {} and sits behind the release environment. Its only capability is starting a build; it cannot touch this repository.
  • verify-dmg.sh sets the quarantine bit itself. Neither gh nor curl sets com.apple.quarantine — only download-aware apps do — so a Gatekeeper check on a freshly downloaded file otherwise runs against something macOS already trusts.

Verification

Local rehearsal of the build half on this layout (unsigned, since forge.config.ts skips osxSign without SIGN_IDENTITY):

  • turbo run build --filter maximal-client --force → sidecar compiled, embeds HEAD 64b9106
  • electron-forge package --arch=arm64 → packages/maximal/client/out/Maximal-darwin-arm64/Maximal.app, matching app_path exactly
  • CFBundleIdentifier = co.stuffbucket.maximal; CFBundleShortVersionString = the stamped tag version
  • sidecar present in the bundle and embeds HEAD; app.asar nonempty
  • the unsigned build reports Signature=adhoc / TeamIdentifier=not set, which is precisely what the three new signing assertions reject — they are live

Also: actionlint clean on both workflows, shellcheck clean on all 9 run: blocks and both scripts, verify-workspace 14/14, lockfile unchanged with 0 recorded hosts.

The signing, notarization and stapling tail cannot be rehearsed here — it only exists on the builder.

Not done in this PR

Onboarding is human-only and the pipeline degrades safely without it: with no MACOS_BUILDER_PAT the dispatch job emits a notice, leaves the draft unfilled, and stays green.

  1. clients/stuffbucket/monimal.policy in the builder, via its build-config issue-ops flow
  2. app-repoman installed here with Contents: read+write
  3. MACOS_BUILDER_PAT (fine-grained, Actions: write on the builder only)
  4. A release environment restricted to tag refs with a required reviewer

Checklist and rationale are in RELEASING.md.

This repository had no release pipeline: ci.yml packaged an unsigned .app on
Ubuntu and discarded it, and the signing path in forge.config.ts was inert
because nothing supplied SIGN_IDENTITY.

Restore the client half of the stuffbucket/macos-builder contract, adapted to
the pnpm/turbo monorepo layout rather than maximal's npm/client/ layout:

- .macos-builder/config declares what to build and owns the asset name.
- .macos-builder/build.sh builds and inside-out signs only the .app. It
  bootstraps pnpm at the packageManager version into scratch rather than asking
  the builder to supply it, repairs the lockfile before installing, stamps the
  tag version after installing, bypasses the cached turbo `package` task so a
  cache hit cannot restore a foreign bundle, and asserts Developer ID plus
  hardened runtime locally instead of letting Apple reject it minutes later.
- release.yml goes tag -> draft -> dispatch -> wait -> verify. It never
  publishes; publishing stays deliberate and manual. The dispatch job holds no
  repository permissions and sits behind the `release` environment.
- scripts/verify-dmg.sh is the Gatekeeper acceptance test. It applies a
  quarantine attribute explicitly, because neither gh nor curl sets one and a
  check on an unquarantined file proves nothing about what a user gets.

No Apple credential enters this repository. The builder keeps the keychain,
the Apple ID and the notary credentials, and is handed only a signing identity
name and an entitlements path.

The tag is the single owner of the version: the client manifest stays at 0.0.0
and is stamped at build time, so a tag and a bundle version cannot disagree.

Release branches are not adopted yet; release.yml already accepts a tag on
either main or release/*, so adopting them needs no workflow change.
Three defects found by exercising the failure paths:

- `${BUN_INSTALL:-}/bin` collapses to `/bin` when the variable is absent, which
  silently prepends /bin to PATH. Guard each prepend on the variable actually
  being set.
- Use `if` rather than `test && export`. Under set -e a trailing AND-OR list
  whose test fails carries its non-zero status out, so the && form is safe only
  at the exact position it currently occupies.
- `bun --version` in the preflight log aborted with no explanation when bun was
  missing, pre-empting the named assertion below it. Tolerate it there and add
  an explicit `command -v bun` check that says what is wrong.

All five input-validation paths verified to produce a named ::error::.
@stuffbucket
stuffbucket merged commit 2409937 into main Sep 1, 2026
6 checks passed
@stuffbucket
stuffbucket deleted the feat/signed-macos-release branch September 2, 2026 00:52
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.

1 participant