name: macOS signed build # Builds the release-identity Hex.app (anomaly.hex), signs it with Anomaly's # Developer ID, notarizes and staples the app and its DMG, validates it, and # uploads the DMG as this run's artifact. Nothing is published. Without the # Apple secrets in the release environment the build is skipped; the # unsigned test builds remain the fallback. See docs/plans/macos-signing.md. on: workflow_dispatch: permissions: contents: read concurrency: group: macos-signed-${{ github.ref }} cancel-in-progress: true jobs: credentials: if: github.repository == 'anomalyco/hex' runs-on: ubuntu-24.04 environment: release outputs: available: ${{ steps.check.outputs.available }} steps: - id: check 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: | if [ -n "$APPLE_CERTIFICATE" ] && [ -n "$APPLE_CERTIFICATE_PASSWORD" ] \ && [ -n "$APPLE_API_KEY_PATH" ] && [ -n "$APPLE_API_KEY" ] && [ -n "$APPLE_API_ISSUER" ]; then echo "available=true" >> "$GITHUB_OUTPUT" else echo "available=false" >> "$GITHUB_OUTPUT" echo "Apple signing secrets are not configured in the release environment; skipping the signed build. See docs/plans/macos-signing.md." >> "$GITHUB_STEP_SUMMARY" fi build: name: macOS arm64 (Developer ID) needs: credentials if: needs.credentials.outputs.available == 'true' runs-on: macos-26 environment: release timeout-minutes: 120 env: VOICE_CONTROL_TEAM_ID: 5NZ4Q7NXJ4 steps: - uses: actions/checkout@v7 with: persist-credentials: false - 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 "No Developer ID Application identity for team $VOICE_CONTROL_TEAM_ID in the imported certificate." >&2 exit 1 fi key="$RUNNER_TEMP/notary-key.p8" (umask 077; printf '%s\n' "$APPLE_API_KEY_PATH" > "$key") { echo "VOICE_CONTROL_CODESIGN_IDENTITY=$identity" echo "HEX_NOTARY_KEY=$key" echo "VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')" echo "SHORT=$(git rev-parse --short=7 HEAD)" } >> "$GITHUB_ENV" - name: Build, sign, and notarize Hex.app env: HEX_NOTARY_KEY_ID: ${{ secrets.APPLE_API_KEY }} HEX_NOTARY_ISSUER: ${{ secrets.APPLE_API_ISSUER }} run: | scripts/setup.sh bundle=$(scripts/build-app.sh) build_number=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$bundle/Contents/Info.plist") scripts/validate-app.sh "$bundle" Hex.app "$VERSION" "$build_number" mkdir -p dist scripts/notarize-app.sh "$bundle" "dist/Hex-$VERSION-$SHORT-arm64.dmg" Hex scripts/smoke-macos-app.sh "$bundle" - name: Remove the notary key if: always() run: rm -f "$RUNNER_TEMP/notary-key.p8" - uses: actions/upload-artifact@v7 with: name: hex-signed-${{ env.SHORT }}-macos-arm64 path: dist/Hex-${{ env.VERSION }}-${{ env.SHORT }}-arm64.dmg retention-days: 14 if-no-files-found: error