SPB Git

Repository Public License

notarize.sh 1.8 KB 37 lines shellscript

1#!/usr/bin/env bash2# ORIX OS Automation3# File: Scripts/release/notarize.sh4# Description: Submits an artifact (.app, .dmg or .zip) to Apple's notary service with an EXISTING keychain profile, waits for the verdict and staples on acceptance.5#6# Author: Simon-Pierre Boucher7# Contact: contact@spboucher.ai8#   Scripts/notarize.sh <artifact> <name>9#   NOTARY_PROFILE  keychain profile created earlier with `xcrun notarytool store-credentials` (default: MacLustr-Notarize).10# This script never creates, prints or changes credentials. "notarized" is printed only when Apple answered Accepted.11set -euo pipefail12cd "$(dirname "$0")/../.."13PROFILE="${NOTARY_PROFILE:-MacLustr-Notarize}"14ARTIFACT="$1"; NAME="$2"15mkdir -p build/notary16SUBMIT="$ARTIFACT"17if [[ -d "$ARTIFACT" ]]; then18  SUBMIT="build/notary/$NAME-submit.zip"; rm -f "$SUBMIT"19  ditto -c -k --keepParent "$ARTIFACT" "$SUBMIT"20fi21OUT="build/notary/$NAME.json"22if ! xcrun notarytool submit "$SUBMIT" --keychain-profile "$PROFILE" --wait --output-format json >"$OUT" 2>"$OUT.err"; then23  echo "Notary service refused the submission of $ARTIFACT:" >&2; sed 's/^/  /' "$OUT.err" | head -8 >&2; exit 224fi25STATUS="$(/usr/bin/python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("status",""))' "$OUT")"26ID="$(/usr/bin/python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("id",""))' "$OUT")"27echo "Submission $ID: $STATUS"28xcrun notarytool log "$ID" --keychain-profile "$PROFILE" "build/notary/$NAME-log.json" >/dev/null 2>&1 || true29if [[ "$STATUS" != "Accepted" ]]; then30  echo "RESULT: $ARTIFACT is NOT notarized. See build/notary/$NAME-log.json" >&2; exit 331fi32if [[ "$ARTIFACT" != *.zip ]]; then33  xcrun stapler staple "$ARTIFACT" >/dev/null34  xcrun stapler validate "$ARTIFACT"35fi36echo "RESULT: $ARTIFACT is notarized by Apple (submission $ID)."37
Files main
Menu

Theme