SPB Git

Repository Public

finalize.sh 2.4 KB 34 lines shellscript

1#!/usr/bin/env bash2# ORIX DJ3# File: Scripts/finalize.sh4# Description: After the DMG is notarized and stapled: verifies Gatekeeper on the app, the DMG and the ZIP content, writes SHA-256 checksums and dist/release.json with measured values only.5#6# Author: Simon-Pierre Boucher7# Contact: contact@spboucher.ai8set -euo pipefail9cd "$(dirname "$0")/.."10APP="dist/ORIX DJ.app"11VERSION="$(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' "$APP/Contents/Info.plist")"12BUILD="$(/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' "$APP/Contents/Info.plist")"13MIN="$(/usr/libexec/PlistBuddy -c 'Print LSMinimumSystemVersion' "$APP/Contents/Info.plist")"14DMG="dist/ORIX-DJ-$VERSION.dmg"; ZIP="dist/ORIX-DJ-$VERSION.zip"15echo "== Gatekeeper"16spctl --assess --type execute --verbose=2 "$APP" 2>&1 | sed 's/^/  /'17spctl --assess --type open --context context:primary-signature --verbose=2 "$DMG" 2>&1 | sed 's/^/  /'18xcrun stapler validate "$APP"; xcrun stapler validate "$DMG"19T="$(mktemp -d)"; ditto -x -k "$ZIP" "$T"; spctl --assess --type execute --verbose=2 "$T/ORIX DJ.app" 2>&1 | sed 's/^/  zip: /'; xcrun stapler validate "$T/ORIX DJ.app" | sed 's/^/  zip: /'; rm -rf "$T"20(cd dist && shasum -a 256 "$(basename "$DMG")" "$(basename "$ZIP")" | tee SHA256SUMS.txt)21APPID="$(/usr/bin/python3 -c 'import json;print(json.load(open("build/notary/app.json"))["id"])' 2>/dev/null || echo "")"22DMGID="$(/usr/bin/python3 -c 'import json;print(json.load(open("build/notary/dmg.json"))["id"])' 2>/dev/null || echo "")"23/usr/bin/python3 - "$VERSION" "$BUILD" "$MIN" "$DMG" "$ZIP" "$APPID" "$DMGID" "$(lipo -archs "$APP/Contents/MacOS/ORIX DJ")" <<'PY'24import json, os, sys, hashlib25v, b, m, dmg, zp, appid, dmgid, archs = sys.argv[1:]26def sha(p): return hashlib.sha256(open(p, 'rb').read()).hexdigest()27meta = {"name": "ORIX DJ", "bundleIdentifier": "ai.spboucher.orix.dj", "version": v, "build": b, "minimumMacOS": m,28        "architectures": archs.split(), "signing": "Developer ID Application, Hardened Runtime",29        "notarization": {k: {"submission": i, "status": json.load(open(f"build/notary/{k}.json")).get("status", "unknown") if i else "unknown"} for k, i in (("app", appid), ("dmg", dmgid))},30        "artifacts": [{"file": os.path.basename(p), "bytes": os.path.getsize(p), "sha256": sha(p)} for p in (dmg, zp)]}31json.dump(meta, open("dist/release.json", "w"), indent=1)32print(json.dumps(meta, indent=1))33PY34
Files main
Menu

Theme