Skip to content

Commit f17ef17

Browse files
committed
Add separate notarizing jobs
1 parent 56371e4 commit f17ef17

File tree

11 files changed

+762
-258
lines changed

11 files changed

+762
-258
lines changed

.github/workflows/ci.yml

Lines changed: 322 additions & 82 deletions
Large diffs are not rendered by default.

.github/workflows/ci/helpers.sh

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,19 @@ analyze_set_job_skip_cache_key()
234234

235235
analyze_set_job_skip_job()
236236
{
237+
# TODO add back
238+
#if [[ "${job_type:-}" == "notarize" ]]; then
239+
# case "$GITHUB_EVENT_NAME:$GITHUB_REF" in
240+
# push:refs/heads/main|push:refs/heads/maintenance/*|push:refs/tags/v*)
241+
# : ;; # allowed; continue to normal skip logic below
242+
# *)
243+
# skip_job='yes'
244+
# info "Skip $job_name? $skip_job (notarize allowed only on push to main, maintenance/*, or v* tag; event=$GITHUB_EVENT_NAME ref=$GITHUB_REF)"
245+
# echo "${job_id}_skip_job=$skip_job" >> $GITHUB_OUTPUT
246+
# return
247+
# ;;
248+
# esac
249+
#fi
237250
if [ "$is_release" = "no" -a -e "$job_skip_cache_path" ]
238251
then
239252
run_link="$(< "$job_skip_cache_path")" || die
@@ -246,6 +259,91 @@ analyze_set_job_skip_job()
246259
echo "${job_id}_skip_job=$skip_job" >> $GITHUB_OUTPUT
247260
}
248261

262+
# Install Developer ID certificate into a temporary keychain
263+
#
264+
# Env vars required:
265+
# MACOS_CODESIGN_CERT_P12_BASE64
266+
# MACOS_CODESIGN_CERT_PASSWORD
267+
# MACOS_TEMP_KEYCHAIN_NAME
268+
# MACOS_TEMP_KEYCHAIN_PASSWORD
269+
#
270+
# Side effects:
271+
# - Creates/unlocks ${MACOS_TEMP_KEYCHAIN_NAME}.keychain
272+
# - Adds it first in the user keychain search list
273+
# - Imports the Developer ID identity (.p12)
274+
# - Configures key partition list for non-interactive codesign
275+
install_dev_id_cert_into_temp_keychain() {
276+
set -euo pipefail
277+
278+
: "${MACOS_CODESIGN_CERT_P12_BASE64:?Missing secret MACOS_CODESIGN_CERT_P12_BASE64}"
279+
: "${MACOS_CODESIGN_CERT_PASSWORD:?Missing secret MACOS_CODESIGN_CERT_PASSWORD}"
280+
: "${MACOS_TEMP_KEYCHAIN_PASSWORD:?Missing secret MACOS_TEMP_KEYCHAIN_PASSWORD}"
281+
: "${MACOS_TEMP_KEYCHAIN_NAME:?MACOS_TEMP_KEYCHAIN_NAME not set}"
282+
283+
KC_FILE="${MACOS_TEMP_KEYCHAIN_NAME}.keychain"
284+
KC_DB="${HOME}/Library/Keychains/${MACOS_TEMP_KEYCHAIN_NAME}.keychain-db"
285+
286+
# Clean any stale keychain (both list entry and on-disk file)
287+
if security list-keychains -d user | grep -q "$KC_FILE"; then
288+
security -q delete-keychain "$KC_FILE" || true
289+
fi
290+
rm -f "$KC_DB" || true
291+
292+
# Create & unlock keychain (6h auto-lock)
293+
security -q create-keychain -p "$MACOS_TEMP_KEYCHAIN_PASSWORD" "$KC_FILE"
294+
security -q set-keychain-settings -lut 21600 "$KC_FILE"
295+
security -q unlock-keychain -p "$MACOS_TEMP_KEYCHAIN_PASSWORD" "$KC_FILE"
296+
297+
# Put our keychain first in the search list (keep existing ones)
298+
existing="$(security list-keychains -d user | tr -d ' \"')"
299+
security -q list-keychains -d user -s "$KC_FILE" $existing
300+
301+
# Decode the .p12 file
302+
echo "$MACOS_CODESIGN_CERT_P12_BASE64" | base64 --decode > signing.p12
303+
304+
# Import identity and always remove the .p12 file
305+
security import signing.p12 -k "$KC_FILE" -P "$MACOS_CODESIGN_CERT_PASSWORD" \
306+
-T /usr/bin/codesign -T /usr/bin/security >/dev/null; rm -f signing.p12
307+
308+
# Allow codesign to use the private key non-interactively
309+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s \
310+
-k "$MACOS_TEMP_KEYCHAIN_PASSWORD" "$KC_FILE" >/dev/null
311+
312+
# Sanity check: can we see a codesigning identity in this keychain?
313+
if ! security find-identity -p codesigning -v "$KC_FILE" | grep -q "Developer ID Application"; then
314+
echo "No Developer ID Application identity found in ${MACOS_TEMP_KEYCHAIN_NAME}.keychain" >&2
315+
return 1
316+
fi
317+
}
318+
319+
# Cleanup the temporary keychain created for codesigning
320+
#
321+
# Env vars required:
322+
# MACOS_TEMP_KEYCHAIN_NAME
323+
# Optional env:
324+
# MACOS_CODESIGN_KEYCHAIN # if set, will be used as the keychain file name
325+
#
326+
# Side effects:
327+
# - Deletes the keychain and its on-disk DB
328+
# - Clears MACOS_CODESIGN_KEYCHAIN from the GitHub Actions environment (if available)
329+
cleanup_dev_id_temp_keychain() {
330+
set -euo pipefail
331+
332+
: "${MACOS_TEMP_KEYCHAIN_NAME:?MACOS_TEMP_KEYCHAIN_NAME not set}"
333+
334+
# Respect an explicit keychain override if provided; otherwise derive from the temp name
335+
KC_FILE="${MACOS_CODESIGN_KEYCHAIN:-${MACOS_TEMP_KEYCHAIN_NAME}.keychain}"
336+
KC_DB="${HOME}/Library/Keychains/${MACOS_TEMP_KEYCHAIN_NAME}.keychain-db"
337+
338+
security -q delete-keychain "$KC_FILE" || true
339+
rm -f "$KC_DB" || true
340+
341+
# Clear env for downstream steps only when running in GitHub Actions
342+
if [[ -n "${GITHUB_ENV:-}" && -w "${GITHUB_ENV}" ]]; then
343+
echo "MACOS_CODESIGN_KEYCHAIN=" >> "$GITHUB_ENV"
344+
fi
345+
}
346+
249347
python='python3'
250348

251349
exec 2>&1

.github/workflows/ci/workflow_context.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,30 @@ jobs:
9393
skiplists: ["job_build", "os_linux"]
9494
- <<: *build
9595
<<: *dist_macos
96+
variant: macOS App
9697
needs: [test_macos]
9798
cache_extra_deps: ["reqs/dist_*.txt", "osx/deps.sh"]
9899
skiplists: ["job_build", "os_macos"]
100+
- <<: *dist_macos
101+
type: notarize
102+
variant: macOS App
103+
needs: [build_macos_app]
104+
reqs: ["build", "setup"]
105+
cache_extra_deps: ["reqs/dist_*.txt", "osx/deps.sh"]
106+
skiplists: ["job_build", "os_macos"]
107+
- <<: *build
108+
<<: *dist_macos
109+
variant: macOS DMG
110+
needs: [build_macos_app, notarize_macos_app]
111+
cache_extra_deps: ["reqs/dist_*.txt", "osx/deps.sh"]
112+
skiplists: ["job_build", "os_macos"]
113+
- <<: *dist_macos
114+
type: notarize
115+
variant: macOS DMG
116+
needs: [build_macos_dmg]
117+
reqs: ["build", "setup"]
118+
cache_extra_deps: ["reqs/dist_*.txt", "osx/deps.sh"]
119+
skiplists: ["job_build", "os_macos"]
99120
- <<: *build
100121
<<: *dist_win
101122
needs: [test_windows]

0 commit comments

Comments
 (0)