11#! /usr/bin/env bash
22
3- # Submits a signed standalone macOS binary to Apple notarization through
4- # rcodesign. Standalone binaries cannot carry a stapled ticket, so the binary
5- # is submitted in a ZIP and the successful notarization log is retained.
3+ # Notarize a standalone binary and retain its diagnostic report.
64
75set -euo pipefail
86
97usage () {
108 cat >&2 << 'EOF '
11- Usage: notarize_macos_binary_with_rcodesign .sh --binary PATH [--report-dir PATH] [--max-wait-seconds SECONDS]
9+ Usage: notarize_macos_binary_with_akv .sh --binary PATH [--report-dir PATH] [--max-wait-seconds SECONDS]
1210
1311Options:
1412 --binary PATH Signed standalone macOS binary to notarize.
1513 --report-dir PATH Directory for notarization logs.
16- --max-wait-seconds SECONDS Maximum rcodesign notarization wait time.
14+ --max-wait-seconds SECONDS Maximum Apple notarization wait time.
1715EOF
1816}
1917
@@ -63,7 +61,7 @@ if [[ ! "$max_wait_seconds" =~ ^[0-9]+$ ]]; then
6361 exit 2
6462fi
6563
66- for command_name in rcodesign zip; do
64+ for command_name in python3 zip; do
6765 if ! command -v " $command_name " > /dev/null 2>&1 ; then
6866 echo " $command_name was not found on PATH." >&2
6967 exit 1
7371missing_environment=0
7472for variable_name in \
7573 APPLE_NOTARIZATION_ISSUER_ID \
76- APPLE_NOTARIZATION_KEY_ID \
77- APPLE_NOTARIZATION_KEY_P8
74+ APPLE_NOTARIZATION_AKV_KEY_NAME \
75+ AZURE_KEYVAULT_NAME
7876do
7977 if [[ -z " ${! variable_name:- } " ]]; then
80- echo " $variable_name must be set from CI secrets before notarizing a binary." >&2
78+ echo " $variable_name must be configured before notarizing a binary." >&2
8179 missing_environment=1
8280 fi
8381done
@@ -91,23 +89,6 @@ mkdir -p "$report_dir"
9189notarization_temp_dir=" $( mktemp -d) "
9290trap ' rm -rf "$notarization_temp_dir" >/dev/null' EXIT
9391
94- private_key_path=" $notarization_temp_dir /AuthKey_${APPLE_NOTARIZATION_KEY_ID} .p8"
95- if ! printf ' %s' " $APPLE_NOTARIZATION_KEY_P8 " | base64 --decode > " $private_key_path " 2> /dev/null; then
96- if ! printf ' %s' " $APPLE_NOTARIZATION_KEY_P8 " | base64 -D > " $private_key_path " 2> /dev/null; then
97- echo " APPLE_NOTARIZATION_KEY_P8 must be a base64-encoded .p8 private key." >&2
98- exit 2
99- fi
100- fi
101- chmod 600 " $private_key_path "
102-
103- api_key_path=" $notarization_temp_dir /app-store-connect-api-key.json"
104- rcodesign encode-app-store-connect-api-key \
105- --output-path " $api_key_path " \
106- " $APPLE_NOTARIZATION_ISSUER_ID " \
107- " $APPLE_NOTARIZATION_KEY_ID " \
108- " $private_key_path " \
109- > " $report_dir /encode-app-store-connect-api-key.log" 2>&1
110-
11192binary_name=" $( basename " $binary_path " ) "
11293archive_path=" $notarization_temp_dir /${binary_name} .zip"
11394(
@@ -116,16 +97,15 @@ archive_path="$notarization_temp_dir/${binary_name}.zip"
11697)
11798
11899notarization_log=" $report_dir /${binary_name} -notarization.log"
119- rcodesign notarize \
120- --api-key-file " $api_key_path " \
100+ python3 " $( dirname " $0 " ) /notarize_with_akv.py" \
101+ --file " $archive_path " \
102+ --report-log " $report_dir /${binary_name} -notarization-developer-log.json" \
121103 --max-wait-seconds " $max_wait_seconds " \
122- --wait \
123- " $archive_path " \
124104 2>&1 | tee " $notarization_log "
125105
126106{
127107 echo " binary_name=$binary_name "
128108 echo " max_wait_seconds=$max_wait_seconds "
129109 echo " binary_sha256=$( shasum -a 256 " $binary_path " | awk ' { print $1 }' ) "
130- echo " rcodesign_notarize =completed"
110+ echo " notarization =completed"
131111} > " $report_dir /${binary_name} -notarization-summary.txt"
0 commit comments