Skip to content

ci(release): sign and notarize the macOS builds - #167

Merged
xevrion merged 5 commits into
mainfrom
ci/macos-sign-notarize
Nov 29, 2026
Merged

xevrion merged 5 commits into
mainfrom
ci/macos-sign-notarize

Conversation

@xevrion

@xevrion xevrion commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

What

The release workflow can now sign the macOS downloads with a Developer ID Application certificate and have Apple notarize them.

  • hatchzip and hatchzip-gui (both architectures) are signed right after the build with codesign --force --timestamp --options runtime, before the smoke tests and the packaging, so the tarballs and their .sha256 hold the signed CLI.
  • build-dmg.sh takes an optional MACOS_SIGN_IDENTITY. With it, it signs the two programs inside HatchZip.app, then the bundle (inside out, no --deep), builds the dmg and signs the dmg. Without it, it runs the same ad hoc commands as before.
  • No entitlements: the app draws with OpenGL (FemtoVG) or the software renderer, has no JIT, loads no unsigned libraries and sends no Apple Events, so the hardened runtime defaults fit. The Objective-C method added at run time for "Open With" doesn't need one either.
  • Each dmg is notarized with notarytool submit --wait --timeout 30m and the ticket stapled. The CLI of each tarball is notarized as a zip of the binary (tar.gz isn't accepted); a bare binary can't be stapled, so Gatekeeper finds that ticket online. The app is not notarized and stapled on its own: the dmg is the outermost container and its ticket covers the app inside, which is Apple's standard flow for a dmg; a copied-out app gets its ticket checked online.
  • A status other than Accepted fails the job and prints notarytool log.
  • "check the signatures" step: Developer ID authority and the runtime flag on the CLI, stapler validate and spctl -a -t open --context context:primary-signature on the dmg, codesign --verify --strict --deep and spctl --assess --type execute on the app inside it. If Gatekeeper is turned off on the runner, spctl reports an override; that is a warning, and stapler still checks the ticket.
  • Order: sign, test, package and checksum the tarballs, build and sign the dmgs, notarize and staple, test the dmg, checksum the dmgs. The publish job's attestation runs on the final files, as before.
  • The certificate goes into a keychain the job creates (random masked password, unlocked, set-key-partition-list, set as the user search list and default), and an if: always() step deletes it. The identity is picked by SHA-1 among "Developer ID Application" identities of APPLE_TEAM_ID; anything other than exactly one fails. The .p12 and .p8 are written to RUNNER_TEMP with mode 600 and removed. No new actions.
  • The job timeout goes from 30 to 90 minutes, for four notarization requests.

How it's gated

MACOS_SIGNING is true when every secret below and APPLE_TEAM_ID are set and either the run is a tag with the variable SIGN_MACOS set to true, or the run is not a tag and SIGN_DRY_RUNS is true (the same rule as Windows). A tag with SIGN_MACOS on but a secret missing fails the job instead of publishing an unsigned app. Otherwise every new step is skipped and the job does what it did before.

Setup for the maintainer

Also in packaging/README.md, "macOS: signing and notarization".

  1. Developer ID Application certificate: Xcode > Settings > Accounts > the team > Manage Certificates > + > Developer ID Application (or upload a CSR at developer.apple.com > Certificates > + > Developer ID Application, G2 Sub-CA). In Keychain Access > My Certificates, export "Developer ID Application: ... (TEAMID)" with its key as cert.p12, with a password.
  2. App Store Connect > Users and Access > Integrations > App Store Connect API > Team Keys: generate a key with the Developer role, download AuthKey_<id>.p8 (only once), note the Key ID and the Issuer ID.
  3. Secrets and variable, read from the files:
    base64 -i cert.p12 | gh secret set MACOS_CERT_P12 --repo xevrion/hatchzip
    gh secret set MACOS_CERT_PASSWORD --repo xevrion/hatchzip   # prompts
    gh secret set APPLE_API_KEY_P8 --repo xevrion/hatchzip < AuthKey_XXXXXXXXXX.p8
    gh secret set APPLE_API_KEY_ID --repo xevrion/hatchzip      # prompts
    gh secret set APPLE_API_ISSUER_ID --repo xevrion/hatchzip   # prompts
    gh variable set APPLE_TEAM_ID --repo xevrion/hatchzip --body XXXXXXXXXX
  4. Dry run: SIGN_DRY_RUNS is already true. Run gh workflow run release --repo xevrion/hatchzip --ref main (or a branch), check the macos job (identity printed, each notarization Accepted, "check the signatures" passes), open a dmg from the macos artifact on a Mac. Then gh variable set SIGN_MACOS --repo xevrion/hatchzip --body true.

Verified

  • actionlint passes on the new steps (its only finding is an existing SC2086 in the linux job).
  • The default path: a dry run of the release workflow on this branch (run 46223494673) with no macOS secrets set. The macos job passed, logged "signing ad hoc", skipped every new step, and built, tested and uploaded the ad hoc signed files as before. The Windows job of that run failed in "sign the programs (SignPath)" with "The parameters 'version', 'innoProductName', 'innoProductVersion' are required", the same failure as the 2026-11-20 dry run on test/mac-preview; this PR doesn't touch the Windows job.

Not verified

  • The signed path. It needs the secrets and a dry run: the keychain import, find-identity parsing, notarization, stapling and the spctl checks have not run anywhere yet.
  • Whether Gatekeeper is on in the macos-15 runner image (if not, the spctl checks only warn).

To update after the first notarized release

These still describe the ad hoc app and stay as they are until a notarized release ships:

  • README.md, the installation note (about line 119) and "Antivirus warnings" (about line 441): "not code-signed yet", "allow it under System Settings, Privacy & Security".
  • packaging/README.md, "macOS: dmg": "signed ad hoc, not with a Developer ID, and not notarized", the Open Anyway, Control-click and xattr -dr com.apple.quarantine instructions.
  • packaging/homebrew/Casks/hatchzip.rb caveats ("signed ad hoc").
  • site/index.html and site/zh.html, the download note ("the macOS apps are not code-signed yet ... allow it in System Settings").
  • site/verify.html, "Antivirus warnings" ("macOS asks you to allow the app in System Settings").
  • site/llms.txt ("not code-signed yet"), site/sponsor.html (macOS signing as something to fund).
  • The comment at the top of packaging/macos/build-dmg.sh already describes both modes.

@xevrion
xevrion merged commit 4426cb5 into main Nov 29, 2026
19 of 20 checks passed
@xevrion
xevrion deleted the ci/macos-sign-notarize branch November 29, 2026 14:12
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