Skip to content

Commit 6b69577

Browse files
committed
Release: macOS signing + notarization are required, not optional (fail on missing secrets or rejection)
1 parent f088395 commit 6b69577

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# - Push a tag like `v0.1.0` → builds everything and publishes a GitHub Release.
44
# - "Run workflow" on the Actions tab → builds everything; download from the run's Artifacts.
55
#
6-
# macOS signing is optional: add these repo secrets and the mac binaries get
7-
# signed with your Developer ID and notarized. Without them they're unsigned.
6+
# macOS binaries are always signed with the Developer ID and notarized; the
7+
# build fails if any of these repo secrets is missing or Apple rejects it:
88
# MACOS_CERT_P12 base64 of a "Developer ID Application" .p12
99
# MACOS_CERT_PASSWORD password of that .p12
1010
# MACOS_SIGN_IDENTITY e.g. "Developer ID Application: Your Name (TEAMID)"
@@ -25,8 +25,6 @@ jobs:
2525
name: ${{ matrix.name }}
2626
runs-on: ${{ matrix.os }}
2727
env:
28-
# `secrets` can't be used in `if:`, so expose "is a cert configured?" as an env var.
29-
HAS_MAC_CERT: ${{ secrets.MACOS_CERT_P12 != '' }}
3028
CGO_ENABLED: "0"
3129
GOOS: ${{ matrix.goos }}
3230
GOARCH: ${{ matrix.goarch }}
@@ -53,8 +51,8 @@ jobs:
5351
EXT=""; [ "$GOOS" = windows ] && EXT=".exe"
5452
go build -trimpath -ldflags "-s -w" -o "dist/agentiloop${EXT}" ./cmd/agentiloop
5553
56-
- name: Sign and notarize (macOS, optional)
57-
if: runner.os == 'macOS' && env.HAS_MAC_CERT == 'true'
54+
- name: Sign and notarize (macOS)
55+
if: runner.os == 'macOS'
5856
env:
5957
MACOS_CERT_P12: ${{ secrets.MACOS_CERT_P12 }}
6058
MACOS_CERT_PASSWORD: ${{ secrets.MACOS_CERT_PASSWORD }}
@@ -63,6 +61,10 @@ jobs:
6361
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
6462
APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
6563
run: |
64+
# Required: never ship an unsigned or un-notarized mac binary.
65+
for v in MACOS_CERT_P12 MACOS_CERT_PASSWORD MACOS_SIGN_IDENTITY APPLE_ID APPLE_TEAM_ID APPLE_APP_PASSWORD; do
66+
[ -n "${!v}" ] || { echo "::error::secret $v is not set"; exit 1; }
67+
done
6668
BIN=dist/agentiloop
6769
KC=$RUNNER_TEMP/build.keychain
6870
echo "$MACOS_CERT_P12" | base64 --decode > "$RUNNER_TEMP/cert.p12"
@@ -73,14 +75,13 @@ jobs:
7375
security set-key-partition-list -S apple-tool:,apple: -s -k ci "$KC"
7476
security list-keychains -d user -s "$KC"
7577
codesign --force --timestamp --options runtime --sign "$MACOS_SIGN_IDENTITY" "$BIN"
76-
# Notarize only when the Apple ID credentials are set; signing alone still works.
77-
if [ -n "$APPLE_ID" ] && [ -n "$APPLE_APP_PASSWORD" ]; then
78-
ditto -c -k "$BIN" "$RUNNER_TEMP/notarize.zip"
79-
xcrun notarytool submit "$RUNNER_TEMP/notarize.zip" --wait \
80-
--apple-id "$APPLE_ID" --team-id "$APPLE_TEAM_ID" --password "$APPLE_APP_PASSWORD"
81-
else
82-
echo "APPLE_ID / APPLE_APP_PASSWORD not set; skipping notarization"
83-
fi
78+
codesign --verify --strict --verbose=2 "$BIN"
79+
ditto -c -k "$BIN" "$RUNNER_TEMP/notarize.zip"
80+
# --wait returns 0 even when Apple rejects; check the status explicitly.
81+
xcrun notarytool submit "$RUNNER_TEMP/notarize.zip" --wait \
82+
--apple-id "$APPLE_ID" --team-id "$APPLE_TEAM_ID" --password "$APPLE_APP_PASSWORD" \
83+
| tee "$RUNNER_TEMP/notary.log"
84+
grep -q "status: Accepted" "$RUNNER_TEMP/notary.log" || { echo "::error::notarization was not accepted"; exit 1; }
8485
8586
- name: Package (macOS / Linux)
8687
if: runner.os != 'Windows'

0 commit comments

Comments
 (0)