SPB Git

Repository Public

notarize.sh 2.6 KB 45 lines shellscript

1#!/bin/bash2# Notarizes dist/ORIX Sheet.app with an EXISTING notarytool keychain profile, staples the ticket, then3# runs Scripts/package.sh (DMG + ZIP), notarizes and staples the DMG, and writes SHA-256 checksums.4#   NOTARY_PROFILE  keychain profile created earlier with `xcrun notarytool store-credentials`5#                   (default: MacLustr-Notarize). This script never creates, prints or changes credentials.6# The word "notarized" is printed only when Apple's service answered Accepted.7set -euo pipefail8cd "$(dirname "$0")/.."9PROFILE="${NOTARY_PROFILE:-MacLustr-Notarize}"10APP="dist/ORIX Sheet.app"11[[ -d "$APP" ]] || { echo "ERROR: $APP not found. Run Scripts/sign.sh first." >&2; exit 1; }12VERSION="$(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' "$APP/Contents/Info.plist")"13mkdir -p build/notary1415submit() {   # submit <file> <name>; succeeds only when the status is Accepted16  local file="$1" out="build/notary/$2.json"17  if ! xcrun notarytool submit "$file" --keychain-profile "$PROFILE" --wait --output-format json >"$out" 2>"$out.err"; then18    echo "Notary service refused the submission of $file:" >&2; sed -e 's/^/  /' "$out.err" | head -8 >&2; return 119  fi20  local status id21  status="$(/usr/bin/python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("status",""))' "$out")"22  id="$(/usr/bin/python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("id",""))' "$out")"23  echo "Submission $id: $status"24  xcrun notarytool log "$id" --keychain-profile "$PROFILE" "build/notary/$2-log.json" >/dev/null 2>&1 || true25  [[ "$status" == "Accepted" ]]26}2728echo "== 1/4 Submitting the application =="29ZIP="build/notary/ORIXSheet-app.zip"; rm -f "$ZIP"30ditto -c -k --keepParent "$APP" "$ZIP"31submit "$ZIP" app || { echo "RESULT: NOT notarized. $APP is signed but carries no notarization ticket." >&2; exit 2; }32echo "== 2/4 Stapling the application =="33xcrun stapler staple "$APP"; xcrun stapler validate "$APP"34echo "== 3/4 Packaging =="35Scripts/package.sh36DMG="dist/ORIXSheet-$VERSION.dmg"37echo "== 4/4 Submitting and stapling the disk image =="38submit "$DMG" dmg || { echo "RESULT: the app is notarized and stapled, the DMG is NOT." >&2; exit 3; }39xcrun stapler staple "$DMG"; xcrun stapler validate "$DMG"40( cd dist && shasum -a 256 "ORIXSheet-$VERSION.dmg" "ORIXSheet-$VERSION.zip" | tee "ORIXSheet-$VERSION.sha256" )41echo "== Gatekeeper =="42spctl --assess --type execute --verbose=2 "$APP" 2>&1 | sed 's/^/  /'43spctl --assess --type open --context context:primary-signature --verbose=2 "$DMG" 2>&1 | sed 's/^/  /'44echo "RESULT: $APP and $DMG are notarized by Apple and stapled."45
Files main
Menu

Theme