From 28cd9c0d4cb6a58af468fc319d2921a82be26478 Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Thu, 22 Oct 2026 09:48:42 -0700 Subject: [PATCH 1/2] ci: check macOS app signing without publishing a release Runs the release's keychain setup, codesign, notarization and stapling on macos-15 for changes to the signing scripts, so a signing fix is proven before a release tag is used. Claude-Session: https://claude.ai/code/session_01LgBKAoFnRMD24bTnkRvNau --- .github/workflows/macos-signing.yml | 67 +++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/macos-signing.yml diff --git a/.github/workflows/macos-signing.yml b/.github/workflows/macos-signing.yml new file mode 100644 index 00000000..b6ada2cd --- /dev/null +++ b/.github/workflows/macos-signing.yml @@ -0,0 +1,67 @@ +name: macOS signing + +# Exercises the release's signing path (temporary keychain, Developer ID +# codesign, notarization, stapling) without publishing anything, so signing +# changes are proven before a release tag is spent. +on: + workflow_dispatch: + pull_request: + paths: + - .github/workflows/macos-signing.yml + - scripts/build-macos-app.sh + - scripts/macos-app.py + - scripts/macos-signing-keychain.sh + +permissions: + contents: read + +jobs: + sign: + name: Sign and notarize Driga.app + # Secrets are not available to forks; only same-repository changes run. + if: github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository + runs-on: macos-15 + timeout-minutes: 30 + env: + GOTOOLCHAIN: local + CGO_ENABLED: "0" + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 + with: + go-version-file: go.mod + check-latest: false + cache: false + + - name: Prepare temporary signing keychain + env: + MACOS_SIGN_P12: ${{ secrets.MACOS_SIGN_P12 }} + MACOS_SIGN_PASSWORD: ${{ secrets.MACOS_SIGN_PASSWORD }} + MACOS_NOTARY_KEY: ${{ secrets.MACOS_NOTARY_KEY }} + MACOS_NOTARY_KEY_ID: ${{ secrets.MACOS_NOTARY_KEY_ID }} + MACOS_NOTARY_ISSUER_ID: ${{ secrets.MACOS_NOTARY_ISSUER_ID }} + run: bash scripts/macos-signing-keychain.sh + + # Names and fingerprints only; no secret material. + - name: Show signing identities + run: | + security list-keychains -d user + security find-identity -v -p codesigning "$DRIGA_SIGNING_KEYCHAIN" + security find-identity -v -p codesigning + + - name: Build, sign and notarize the app + run: | + app="$RUNNER_TEMP/signing-check/Driga.app" + mkdir -p "$app/Contents/MacOS" + go build -trimpath -ldflags "-s -w" -o "$app/Contents/MacOS/driga" ./cmd/driga + bash scripts/build-macos-app.sh "$app/Contents/MacOS/driga" darwin 0.0.0-signing-check false + codesign -dv --verbose=2 "$app" 2>&1 | grep -E '^(Authority|TeamIdentifier|Identifier)=' + + - name: Delete temporary signing keychain + if: always() + run: | + keychain="$RUNNER_TEMP/driga-signing/signing.keychain-db" + if [ -f "$keychain" ]; then security delete-keychain "$keychain"; fi + rm -rf "$RUNNER_TEMP/driga-signing" "$RUNNER_TEMP/signing-check" From b424672f41614459cbbf02a051c706781c41024f Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Thu, 22 Oct 2026 09:51:13 -0700 Subject: [PATCH 2/2] fix: put the temporary signing keychain on the user search list The signing check showed the Developer ID identity valid inside the temporary keychain while the user search list held only login.keychain; codesign then failed with "The specified item could not be found in the keychain" even with --keychain. Add the keychain ahead of the existing ones; delete-keychain in the cleanup step removes it again. Claude-Session: https://claude.ai/code/session_01LgBKAoFnRMD24bTnkRvNau --- .github/workflows/macos-signing.yml | 1 + .github/workflows/release.yml | 1 + scripts/macos-signing-keychain.sh | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/.github/workflows/macos-signing.yml b/.github/workflows/macos-signing.yml index b6ada2cd..3bf520c3 100644 --- a/.github/workflows/macos-signing.yml +++ b/.github/workflows/macos-signing.yml @@ -63,5 +63,6 @@ jobs: if: always() run: | keychain="$RUNNER_TEMP/driga-signing/signing.keychain-db" + # delete-keychain also removes it from the user search list. if [ -f "$keychain" ]; then security delete-keychain "$keychain"; fi rm -rf "$RUNNER_TEMP/driga-signing" "$RUNNER_TEMP/signing-check" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7e71ddfd..72a5c24e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -124,5 +124,6 @@ jobs: if: always() run: | keychain="$RUNNER_TEMP/driga-signing/signing.keychain-db" + # delete-keychain also removes it from the user search list. if [ -f "$keychain" ]; then security delete-keychain "$keychain"; fi rm -rf "$RUNNER_TEMP/driga-signing" diff --git a/scripts/macos-signing-keychain.sh b/scripts/macos-signing-keychain.sh index 2a1a1ee5..80218217 100755 --- a/scripts/macos-signing-keychain.sh +++ b/scripts/macos-signing-keychain.sh @@ -24,6 +24,14 @@ security set-keychain-settings -lut 21600 "$keychain" security unlock-keychain -p "$password" "$keychain" security import "$signing_dir/certificate.p12" -k "$keychain" -P "$MACOS_SIGN_PASSWORD" -T /usr/bin/codesign >/dev/null security set-key-partition-list -S apple-tool:,apple:,codesign: -k "$password" "$keychain" >/dev/null +# codesign on hosted runners resolves the identity through the user search +# list even with --keychain; add ours ahead of the existing keychains. +existing=() +while IFS= read -r line; do + line=${line#"${line%%[![:space:]]*}"}; line=${line#\"}; line=${line%\"} + [ -n "$line" ] && existing+=("$line") +done < <(security list-keychains -d user) +security list-keychains -d user -s "$keychain" "${existing[@]}" # Do not accept an Installer identity or silently choose between certificates. identities=$(security find-identity -v -p codesigning "$keychain") identity=$(sed -n 's/.* \([0-9A-F]\{40\}\) "Developer ID Application:.*"/\1/p' <<< "$identities")