SPB Git

Repository Public License

notarize.sh 3.3 KB 76 lines shellscript

1#!/usr/bin/env bash2# =============================================================================3#                  SP BOUCHER | INFRASTRUCTURE & AUTOMATION4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project          : ORIX Monitor8# File             : Scripts/notarize.sh9# Module           : Scripts10# Repository       : https://git.spboucher.ai/orix-monitor11# Created          : 2026-11-2112# Last Modified    : 2026-11-2113#14# Author           : Simon-Pierre Boucher15# Position         : Professor of Finance16# Institution      : Université du Québec en Outaouais (UQO)17# Organization     : SP Boucher18# Website          : https://spboucher.ai19# Git              : https://git.spboucher.ai20#21# Preferred Contact: support@spboucher.ai22# Technical Contact: dev@spboucher.ai23# Security/Admin   : admin@spboucher.ai24#25# Copyright (c) 202626# Simon-Pierre Boucher27# All rights reserved where applicable. This file is governed by the28# applicable project license, copyright notices and relevant law.29# Existing third-party rights and notices remain unaffected.30#31# License          : Proprietary, all rights reserved (see license file)32# License File     : LICENSE33#34# Do not embed credentials, private keys, access tokens,35# certificates or confidential personal information.36#37# =============================================================================38# END OF SP BOUCHER SOURCE HEADER39# =============================================================================4041# ORIX Monitor42# File: Scripts/notarize.sh43# 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.44#45# Author: Simon-Pierre Boucher46# Contact: contact@spboucher.ai47#   Scripts/notarize.sh <artifact> <name>48#   NOTARY_PROFILE  keychain profile created earlier with `xcrun notarytool store-credentials` (default: MacLustr-Notarize).49# This script never creates, prints or changes credentials. "notarized" is printed only when Apple answered Accepted.50set -euo pipefail51cd "$(dirname "$0")/.."52PROFILE="${NOTARY_PROFILE:-MacLustr-Notarize}"53ARTIFACT="$1"; NAME="$2"54mkdir -p build/notary55SUBMIT="$ARTIFACT"56if [[ -d "$ARTIFACT" ]]; then57  SUBMIT="build/notary/$NAME-submit.zip"; rm -f "$SUBMIT"58  ditto -c -k --keepParent "$ARTIFACT" "$SUBMIT"59fi60OUT="build/notary/$NAME.json"61if ! xcrun notarytool submit "$SUBMIT" --keychain-profile "$PROFILE" --wait --output-format json >"$OUT" 2>"$OUT.err"; then62  echo "Notary service refused the submission of $ARTIFACT:" >&2; sed 's/^/  /' "$OUT.err" | head -8 >&2; exit 263fi64STATUS="$(/usr/bin/python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("status",""))' "$OUT")"65ID="$(/usr/bin/python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("id",""))' "$OUT")"66echo "Submission $ID: $STATUS"67xcrun notarytool log "$ID" --keychain-profile "$PROFILE" "build/notary/$NAME-log.json" >/dev/null 2>&1 || true68if [[ "$STATUS" != "Accepted" ]]; then69  echo "RESULT: $ARTIFACT is NOT notarized. See build/notary/$NAME-log.json" >&2; exit 370fi71if [[ "$ARTIFACT" != *.zip ]]; then72  xcrun stapler staple "$ARTIFACT" >/dev/null73  xcrun stapler validate "$ARTIFACT"74fi75echo "RESULT: $ARTIFACT is notarized by Apple (submission $ID)."76
Files main
Menu

Theme