name: Build macOS release # Builds the release Hex.app from one exact commit, signs it with Anomaly's # Developer ID (team 5NZ4Q7NXJ4), and notarizes and staples the app and its # DMG through scripts/release-app.sh prepare. Uploads one artifact, # hex-macos-arm64, holding the release service targets # (docs/plans/release-service.md): Hex--macos-arm64.zip (root # Hex.app, for the updater) and Hex--macos-arm64.dmg. Publishes # nothing. on: workflow_call: inputs: sha: type: string required: true version: type: string required: true permissions: contents: read jobs: build: name: macOS arm64 (Developer ID) runs-on: macos-26 environment: release timeout-minutes: 120 env: VOICE_CONTROL_TEAM_ID: 5NZ4Q7NXJ4 HEX_VERSION: ${{ inputs.version }} steps: - name: Require the signing secrets env: APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }} APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} APPLE_API_KEY_PATH: ${{ secrets.APPLE_API_KEY_PATH }} APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }} APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }} run: | missing= for name in APPLE_CERTIFICATE APPLE_CERTIFICATE_PASSWORD APPLE_API_KEY_PATH \ APPLE_API_KEY APPLE_API_ISSUER; do eval "value=\${$name}" [ -n "$value" ] || missing="$missing $name" done if [ -n "$missing" ]; then echo "::error::The release environment lacks:$missing. See docs/plans/macos-signing.md." exit 1 fi - uses: actions/checkout@v7 with: ref: ${{ inputs.sha }} persist-credentials: false - name: Check the version run: | actual=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "voice-control") | .version') # Staging publishes a prerelease of it, which release-app.sh stamps in. case "$HEX_VERSION" in "$actual" | "$actual"-dev.[0-9]* | "$actual"-beta.[0-9]*) ;; *) echo "::error::$(git rev-parse --short HEAD) is version $actual, not $HEX_VERSION or a prerelease of it." exit 1 ;; esac - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 with: key: signed-build cache-on-failure: true - uses: astral-sh/setup-uv@v6 - uses: oven-sh/setup-bun@v2 - name: Install the Metal toolchain run: xcrun --sdk macosx metal --version || xcodebuild -downloadComponent MetalToolchain - uses: apple-actions/import-codesign-certs@8f3fb608891dd2244cdab3d69cd68c0d37a7fe93 # v2.0.0 with: keychain: build p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }} p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }} - name: Select the signing identity and notary key env: APPLE_API_KEY_PATH: ${{ secrets.APPLE_API_KEY_PATH }} run: | identity=$(security find-identity -v -p codesigning build.keychain \ | sed -n "s/.*\"\(Developer ID Application:.*($VOICE_CONTROL_TEAM_ID)\)\"/\1/p" | head -1) if [ -z "$identity" ]; then echo "::error::No Developer ID Application identity for team $VOICE_CONTROL_TEAM_ID in APPLE_CERTIFICATE." exit 1 fi (umask 077; printf '%s\n' "$APPLE_API_KEY_PATH" > "$RUNNER_TEMP/notary-key.p8") { echo "VOICE_CONTROL_CODESIGN_IDENTITY=$identity" echo "HEX_NOTARY_KEY=$RUNNER_TEMP/notary-key.p8" } >> "$GITHUB_ENV" - name: Build, sign, and notarize env: HEX_NOTARY_KEY_ID: ${{ secrets.APPLE_API_KEY }} HEX_NOTARY_ISSUER: ${{ secrets.APPLE_API_ISSUER }} run: | scripts/setup.sh scripts/release-app.sh prepare - name: Remove the notary key if: always() run: rm -f "$RUNNER_TEMP/notary-key.p8" - name: Check the prepared release run: | dmg="dist/Hex-$HEX_VERSION-macos-arm64.dmg" zip="dist/Hex-$HEX_VERSION-macos-arm64.zip" xcrun stapler validate "$dmg" spctl --assess --type open --context context:primary-signature --verbose=2 "$dmg" check=$(mktemp -d) hdiutil attach -quiet -nobrowse -readonly -mountpoint "$check/dmg" "$dmg" /usr/bin/ditto -x -k "$zip" "$check/update" build=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$check/dmg/Hex.app/Contents/Info.plist") scripts/validate-app.sh "$check/dmg/Hex.app" Hex.app "$HEX_VERSION" "$build" scripts/validate-app.sh "$check/update/Hex.app" Hex.app "$HEX_VERSION" "$build" xcrun stapler validate "$check/update/Hex.app" # What the in-app updater requires before it swaps the bundle in. codesign --verify --deep --strict -R="$(cat app/update-requirement.txt)" "$check/update/Hex.app" spctl --assess --type execute --verbose=2 "$check/dmg/Hex.app" diff -qr "$check/dmg/Hex.app" "$check/update/Hex.app" scripts/smoke-macos-app.sh "$check/dmg/Hex.app" hdiutil detach -quiet "$check/dmg" mkdir -p release cp "$dmg" "$zip" release/ ls -l release >> "$GITHUB_STEP_SUMMARY" - uses: actions/upload-artifact@v7 with: name: hex-macos-arm64 path: release/ retention-days: 30 if-no-files-found: error