SPB Git

Repository Public

notarize.sh 1.6 KB 29 lines shellscript

1#!/usr/bin/env bash2# ORIX DJ3# File: Scripts/notarize.sh4# Description: Notarizes "dist/ORIX DJ.app" (or the file given) with an EXISTING notarytool keychain profile and staples the ticket. NOTARY_PROFILE defaults to MacLustr-Notarize. Never creates, prints or changes credentials. "notarized" is printed only when Apple answered Accepted.5#6# Author: Simon-Pierre Boucher7# Contact: contact@spboucher.ai8set -euo pipefail9cd "$(dirname "$0")/.."10PROFILE="${NOTARY_PROFILE:-MacLustr-Notarize}"11TARGET="${1:-dist/ORIX DJ.app}"12NAME="${2:-app}"13[[ -e "$TARGET" ]] || { echo "ERROR: $TARGET not found. Run Scripts/sign.sh first." >&2; exit 1; }14mkdir -p build/notary15SUBMIT="$TARGET"16if [[ -d "$TARGET" ]]; then SUBMIT="build/notary/$NAME.zip"; rm -f "$SUBMIT"; ditto -c -k --keepParent "$TARGET" "$SUBMIT"; fi17OUT="build/notary/$NAME.json"18if ! xcrun notarytool submit "$SUBMIT" --keychain-profile "$PROFILE" --wait --output-format json >"$OUT" 2>"$OUT.err"; then19  echo "Notary service refused the submission:" >&2; head -8 "$OUT.err" >&2; exit 220fi21STATUS="$(/usr/bin/python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("status",""))' "$OUT")"22ID="$(/usr/bin/python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("id",""))' "$OUT")"23echo "submission $ID: $STATUS"24xcrun notarytool log "$ID" --keychain-profile "$PROFILE" "build/notary/$NAME-log.json" >/dev/null 2>&1 || true25[[ "$STATUS" == "Accepted" ]] || { echo "RESULT: NOT notarized. See build/notary/$NAME-log.json" >&2; exit 3; }26xcrun stapler staple "$TARGET"27xcrun stapler validate "$TARGET"28echo "RESULT: $TARGET is notarized by Apple (submission $ID) and stapled."29
Files main
Menu

Theme