From 3a8c484f7dab54251e1f7d2476a9e0f122173fbf Mon Sep 17 00:00:00 2001 From: Simon Chan Date: Mon, 16 Nov 2026 15:45:38 +0000 Subject: [PATCH] ci: code sign macOS binaries only when APPLE_NOTARIZE is true Releases fail at the certificate import while the Apple certificate is unavailable, even with notarization off. --- .github/workflows/release-please.yml | 8 ++++++-- .github/workflows/release.yml | 6 +++++- README.md | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index acff6217..7e5b4f0f 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -94,8 +94,9 @@ jobs: config-file: release-please-config.json manifest-file: .release-please-manifest.json - # Build, sign and notarize (requires macOS for Apple signing). Notarization runs only when the - # repository variable APPLE_NOTARIZE is "true". + # Build, sign and notarize (requires macOS for Apple signing). + # Code signing and notarization run only when the repository variable APPLE_NOTARIZE is "true". + # Otherwise darwin/arm64 keeps the ad-hoc signature Go's linker gives it. build: needs: release-please if: ${{ needs.release-please.outputs.release_created == 'true' }} @@ -112,6 +113,7 @@ jobs: persist-credentials: false - name: Import codesign cert + if: vars.APPLE_NOTARIZE == 'true' uses: apple-actions/import-codesign-certs@63fff01cd422d4b7b855d40ca1e9d34d2de9427d # v3.0.0 with: p12-file-base64: ${{ secrets.APPLE_CERT_P12_BASE64_ENCODED }} @@ -158,11 +160,13 @@ jobs: done - name: Code sign darwin binaries + if: vars.APPLE_NOTARIZE == 'true' run: | codesign --timestamp --options=runtime -s "Developer ID Application: Nexmo Inc. (7F2B5ZSP8Q)" -v dist/vcr_darwin_amd64 codesign --timestamp --options=runtime -s "Developer ID Application: Nexmo Inc. (7F2B5ZSP8Q)" -v dist/vcr_darwin_arm64 - name: Verify code signing + if: vars.APPLE_NOTARIZE == 'true' run: | codesign -vvv --deep --strict dist/vcr_darwin_amd64 codesign -vvv --deep --strict dist/vcr_darwin_arm64 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index db19f907..c304a9e5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -129,7 +129,8 @@ jobs: make_latest: ${{ contains(inputs.tag, '-') && 'false' || 'true' }} # Build, sign and notarize (requires macOS for Apple signing). Only main reaches this job. - # Notarization runs only when the repository variable APPLE_NOTARIZE is "true". + # Code signing and notarization run only when the repository variable APPLE_NOTARIZE is "true". + # Otherwise darwin/arm64 keeps the ad-hoc signature Go's linker gives it. build: if: github.ref == 'refs/heads/main' needs: draft @@ -145,6 +146,7 @@ jobs: persist-credentials: false - name: Import codesign cert + if: vars.APPLE_NOTARIZE == 'true' uses: apple-actions/import-codesign-certs@63fff01cd422d4b7b855d40ca1e9d34d2de9427d # v3.0.0 with: p12-file-base64: ${{ secrets.APPLE_CERT_P12_BASE64_ENCODED }} @@ -191,11 +193,13 @@ jobs: done - name: Code sign darwin binaries + if: vars.APPLE_NOTARIZE == 'true' run: | codesign --timestamp --options=runtime -s "Developer ID Application: Nexmo Inc. (7F2B5ZSP8Q)" -v dist/vcr_darwin_amd64 codesign --timestamp --options=runtime -s "Developer ID Application: Nexmo Inc. (7F2B5ZSP8Q)" -v dist/vcr_darwin_arm64 - name: Verify code signing + if: vars.APPLE_NOTARIZE == 'true' run: | codesign -vvv --deep --strict dist/vcr_darwin_amd64 codesign -vvv --deep --strict dist/vcr_darwin_arm64 diff --git a/README.md b/README.md index 412bf7db..f7530224 100644 --- a/README.md +++ b/README.md @@ -182,7 +182,7 @@ This project uses [Release Please](https://github.com/googleapis/release-please) 3. **Draft release**: When the Release PR is merged, lint and the tests run, then a draft GitHub Release is created 4. **Build, sign & publish**: The release triggers the build pipeline which: - Cross-compiles binaries for all platforms - - Code signs macOS binaries, and notarizes them when the repository variable `APPLE_NOTARIZE` is `true` + - Code signs and notarizes macOS binaries when the repository variable `APPLE_NOTARIZE` is `true` - Signs `checksums.txt` with the release key (see [Verifying a download](#verifying-a-download)) - Uploads the archives, the checksums and the signature to the draft, then publishes it - Installs the published release and checks that it reports the new version