Skip to content

Commit 1d7a773

Browse files
committed
ci: create notarytool profile in CI temp keychain
Fix: the previous release workflow assumed 'xcrun notarytool submit --keychain-profile' could read the profile from any keychain, but notarytool looks for the profile in the keychain search list. The CI temp keychain doesn't have the profile (it lives in the developer's local login keychain). Solution: CI now uses 3 additional secrets to recreate the profile in the temp keychain after importing the .p12: MACOS_KEYCHAIN_PROFILE profile name (e.g. 'ado-notary') MACOS_NOTARY_APPLE_ID Apple ID used for the profile MACOS_NOTARY_TEAM_ID Team ID (defaults to 87R27UKGSF in CI) MACOS_NOTARY_PASSWORD app-specific password from appleid.apple.com Updated: - ci.yml: Notarize step now does 'xcrun notarytool store-credentials' to recreate the profile in the temp keychain, then uses --keychain-profile to submit. - SIGNING.md: documents all 7 secrets - bin/setup-gh-secrets.sh: prompts for the 3 new notarytool secrets interactively (4/7, 5/7, 6/7, 7/7)
1 parent 693ec4d commit 1d7a773

3 files changed

Lines changed: 76 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,20 +417,38 @@ jobs:
417417
- name: Notarize macOS binary
418418
if: matrix.sign == 'true'
419419
env:
420+
# Profile name + the underlying Apple ID + app-specific password
421+
# needed to recreate the profile in the temp keychain.
422+
# (The profile itself only lives in the developer's local
423+
# keychain; the CI runner has its own fresh keychain.)
420424
MACOS_KEYCHAIN_PROFILE: ${{ secrets.MACOS_KEYCHAIN_PROFILE }}
425+
MACOS_NOTARY_APPLE_ID: ${{ secrets.MACOS_NOTARY_APPLE_ID }}
426+
MACOS_NOTARY_TEAM_ID: ${{ secrets.MACOS_NOTARY_TEAM_ID || '87R27UKGSF' }}
427+
MACOS_NOTARY_PASSWORD: ${{ secrets.MACOS_NOTARY_PASSWORD }}
421428
run: |
422429
set -euo pipefail
423-
if [[ -z "${MACOS_KEYCHAIN_PROFILE}" ]]; then
424-
echo "::warning::MACOS_KEYCHAIN_PROFILE secret not set; skipping notarization."
430+
BINARY=$(ls release_bin/ado-*)
431+
if [[ -z "${MACOS_KEYCHAIN_PROFILE}" || -z "${MACOS_NOTARY_APPLE_ID}" || -z "${MACOS_NOTARY_PASSWORD}" ]]; then
432+
echo "::warning::MACOS_KEYCHAIN_PROFILE / MACOS_NOTARY_APPLE_ID / MACOS_NOTARY_PASSWORD secrets not set; skipping notarization."
425433
echo "::warning::Signed binary is OK for local use but Gatekeeper will warn on first run."
426434
exit 0
427435
fi
428-
BINARY=$(ls release_bin/ado-*)
436+
if [[ ! -f "$MACOS_KEYCHAIN_PATH" ]]; then
437+
echo "::warning::No keychain (cert secrets not set); skipping notarization."
438+
exit 0
439+
fi
440+
echo "Recreating notarytool profile '$MACOS_KEYCHAIN_PROFILE' in temp keychain"
441+
xcrun notarytool store-credentials "$MACOS_KEYCHAIN_PROFILE" \
442+
--apple-id "$MACOS_NOTARY_APPLE_ID" \
443+
--team-id "$MACOS_NOTARY_TEAM_ID" \
444+
--password "$MACOS_NOTARY_PASSWORD" \
445+
--keychain "$MACOS_KEYCHAIN_PATH" \
446+
--keychain-password "$MACOS_KEYCHAIN_PASSWORD"
429447
echo "Submitting for notarization (profile: $MACOS_KEYCHAIN_PROFILE)"
430448
xcrun notarytool submit "$BINARY" \
431449
--keychain-profile "$MACOS_KEYCHAIN_PROFILE" \
432450
--keychain "$MACOS_KEYCHAIN_PATH" \
433-
--keychain-profile-password "$MACOS_KEYCHAIN_PASSWORD" \
451+
--keychain-password "$MACOS_KEYCHAIN_PASSWORD" \
434452
--wait
435453
echo "Stapling notarization ticket"
436454
xcrun stapler staple "$BINARY"

SIGNING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ Go to
9999
| `MACOS_CERT_P12_BASE64` | Base64-encoded `.p12` export of the Developer ID cert (see below) |
100100
| `MACOS_CERT_P12_PASSWORD` | The password you set when exporting the `.p12` |
101101
| `MACOS_KEYCHAIN_PROFILE` | The name of the notarytool profile (e.g. `ado-notary`) |
102+
| `MACOS_NOTARY_APPLE_ID` | The Apple ID used to create the profile (e.g. `you@example.com`) |
103+
| `MACOS_NOTARY_TEAM_ID` | (Optional) Team ID. Defaults to `87R27UKGSF` if unset. Override if your team ID differs. |
104+
| `MACOS_NOTARY_PASSWORD` | The app-specific password from <https://appleid.apple.com> used by the notarytool profile |
105+
106+
> **Why 3 notarytool secrets?** The profile you create locally lives in
107+
> your login keychain. CI runs on a fresh macOS runner with an empty
108+
> keychain, so the workflow recreates the profile in its temp keychain
109+
> using the Apple ID + app-specific password. The profile name
110+
> (`ado-notary`) is the same on both sides.
102111
103112
### One-time: export the .p12 for CI
104113

bin/setup-gh-secrets.sh

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
# MACOS_CERT_P12_PASSWORD the .p12's export password
1212
# MACOS_KEYCHAIN_PROFILE name of a notarytool keychain profile
1313
# (set up with `xcrun notarytool store-credentials`)
14+
# MACOS_NOTARY_APPLE_ID Apple ID used by the notarytool profile
15+
# MACOS_NOTARY_TEAM_ID Team ID (10-char alphanumeric; defaults in CI)
16+
# MACOS_NOTARY_PASSWORD App-specific password for the Apple ID
1417
#
1518
# USAGE:
1619
# bin/setup-gh-secrets.sh # interactive
@@ -20,6 +23,7 @@
2023
# - gh CLI authenticated with repo:admin scope
2124
# - A Developer ID Application certificate in your keychain
2225
# (for the .p12 export)
26+
# - A notarytool keychain profile (for the profile name)
2327
set -euo pipefail
2428

2529
# ── Resolve repo ─────────────────────────────────────────────────────────
@@ -100,7 +104,7 @@ echo
100104

101105
# ── MACOS_KEYCHAIN_PROFILE ──────────────────────────────────────────────
102106

103-
echo "==> 4/4 MACOS_KEYCHAIN_PROFILE"
107+
echo "==> 4/7 MACOS_KEYCHAIN_PROFILE"
104108
if [[ -n "${MACOS_KEYCHAIN_PROFILE:-}" ]]; then
105109
echo " using env var (value hidden)"
106110
else
@@ -115,6 +119,46 @@ fi
115119
set_secret MACOS_KEYCHAIN_PROFILE "notarytool keychain profile name (e.g. 'ado-notary')"
116120
echo
117121

122+
# ── MACOS_NOTARY_APPLE_ID ──────────────────────────────────────────────
123+
124+
echo "==> 5/7 MACOS_NOTARY_APPLE_ID"
125+
if [[ -n "${MACOS_NOTARY_APPLE_ID:-}" ]]; then
126+
echo " using env var (value hidden)"
127+
else
128+
echo " The Apple ID used to create the notarytool profile above."
129+
echo " (Same email you passed to 'xcrun notarytool store-credentials')"
130+
fi
131+
set_secret MACOS_NOTARY_APPLE_ID "Apple ID (e.g. you@example.com)"
132+
echo
133+
134+
# ── MACOS_NOTARY_TEAM_ID ───────────────────────────────────────────────
135+
136+
echo "==> 6/7 MACOS_NOTARY_TEAM_ID"
137+
if [[ -n "${MACOS_NOTARY_TEAM_ID:-}" ]]; then
138+
echo " using env var (value hidden)"
139+
else
140+
echo " Your Apple Developer Team ID (10-char alphanumeric)."
141+
echo " Find yours at https://developer.apple.com/account under Membership,"
142+
echo " or use the 10-char suffix of your signing identity, e.g."
143+
echo " 'Developer ID Application: Your Name (ABCDE12345)' → ABCDE12345"
144+
fi
145+
set_secret MACOS_NOTARY_TEAM_ID "Team ID (10-char alphanumeric, e.g. ABCDE12345)"
146+
echo
147+
148+
# ── MACOS_NOTARY_PASSWORD ──────────────────────────────────────────────
149+
150+
echo "==> 7/7 MACOS_NOTARY_PASSWORD"
151+
if [[ -n "${MACOS_NOTARY_PASSWORD:-}" ]]; then
152+
echo " using env var (value hidden)"
153+
else
154+
echo " The app-specific password from https://appleid.apple.com"
155+
echo " that you used when creating the notarytool profile."
156+
echo " (NOT your Apple ID password — must be a generated"
157+
echo " app-specific password, e.g. 'abcd-efgh-ijkl-mnop')"
158+
fi
159+
set_secret MACOS_NOTARY_PASSWORD "app-specific password (e.g. abcd-efgh-ijkl-mnop)"
160+
echo
161+
118162
# ── Summary ──────────────────────────────────────────────────────────────
119163

120164
echo "==> All secrets set for $REPO"

0 commit comments

Comments
 (0)