SPB Git

Repository Public

notarize.sh 3.2 KB 76 lines shellscript

1#!/usr/bin/env bash2# =============================================================================3#                  SP BOUCHER | INFRASTRUCTURE & AUTOMATION4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project          : ORIX Cosmos8# File             : Scripts/notarize.sh9# Module           : Scripts10# Repository       : https://git.spboucher.ai/orix-cosmos11# Project Website  : https://www.orixlab.dev12# Created          : 2026-11-2413# Last Modified    : 2026-11-2414#15# Author           : Simon-Pierre Boucher16# Position         : Professor of Finance17# Institution      : Université du Québec en Outaouais (UQO)18# Organization     : SP Boucher19# Website          : https://spboucher.ai20# Git              : https://git.spboucher.ai21#22# Preferred Contact: support@spboucher.ai23# Technical Contact: dev@spboucher.ai24# Security/Admin   : admin@spboucher.ai25#26# Copyright (c) 202627# Simon-Pierre Boucher28# All rights reserved where applicable. This file is governed by the29# applicable project license, copyright notices and relevant law.30# Existing third-party rights and notices remain unaffected.31#32# License          : None specified (no license file in this repository)33#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 Cosmos42# File: Scripts/notarize.sh43# Description: Submits an artifact (.app, .dmg or .zip) to Apple's notary service with an EXISTING keychain profile named in the local configuration, waits, and staples only on status Accepted.44#45# Author: Simon-Pierre Boucher46# Contact: contact@spboucher.ai47#   Scripts/notarize.sh <artifact> <label>48# Never creates, prints or changes credentials. "notarized" is printed only when Apple answered Accepted.49set -euo pipefail50cd "$(dirname "$0")/.."51source Scripts/release-config.sh52require_profile53ARTIFACT="$1"; LABEL="$2"54mkdir -p build/notary55SUBMIT="$ARTIFACT"56if [[ -d "$ARTIFACT" ]]; then57  SUBMIT="build/notary/$LABEL-submit.zip"; rm -f "$SUBMIT"58  ditto -c -k --keepParent "$ARTIFACT" "$SUBMIT"59fi60OUT="build/notary/$LABEL.json"61if ! xcrun notarytool submit "$SUBMIT" --keychain-profile "$NOTARY_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 "$NOTARY_PROFILE" "build/notary/$LABEL-log.json" >/dev/null 2>&1 || true68if [[ "$STATUS" != "Accepted" ]]; then69  echo "RESULT: $ARTIFACT is NOT notarized. See build/notary/$LABEL-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