SPB Git

Repository Public

sign.sh 3.2 KB 44 lines shellscript

1#!/usr/bin/env bash2# ORIX Sonata3# File: Scripts/sign.sh4# Description: Builds the Release configuration (arm64, Hardened Runtime), signs nested code inside-out then the app with the Developer ID Application identity already in the keychain, and verifies the result. Produces dist/ORIX Sonata.app. Uploads nothing.5#6# Author: Simon-Pierre Boucher7# Contact: contact@spboucher.ai8set -euo pipefail9cd "$(dirname "$0")/.."10DD="build/DerivedDataRelease"11APP="dist/ORIX Sonata.app"12IDENTITY="$(security find-identity -v -p codesigning | sed -n 's/.*"\(Developer ID Application: [^"]*\)".*/\1/p' | head -1)"13[[ -n "$IDENTITY" ]] || { echo "ERROR: no valid Developer ID Application identity in the keychain." >&2; exit 1; }14Scripts/build-rust.sh release15xcodegen generate --quiet16rm -rf "$DD/Build/Products/Release/ORIX Sonata.app"17xcodebuild -project ORIXSonata.xcodeproj -scheme ORIXSonata -configuration Release -derivedDataPath "$DD" -destination 'platform=macOS,arch=arm64' build 2>&1 | sed 's/\x1b\[[0-9;]*m//g' | grep -E "error:|\*\* BUILD" | sort -u18BUILT="$DD/Build/Products/Release/ORIX Sonata.app"19[[ -d "$BUILT" ]] || { echo "ERROR: Release build failed." >&2; exit 1; }20rm -rf "$APP" && mkdir -p dist21ditto "$BUILT" "$APP"22# Command-line tools shipped inside the bundle (optional CLI install copies them out).23HELPERS="$APP/Contents/Helpers"24mkdir -p "$HELPERS"25cp target/aarch64-apple-darwin/release/sonata target/aarch64-apple-darwin/release/sonata-lsp "$HELPERS/"26# Inside-out: helpers and any nested code first, each with its own signature, then the app. No --deep.27ENT="Distribution/ORIXSonata.entitlements"28while IFS= read -r -d '' item; do29  codesign --force --timestamp --options runtime --sign "$IDENTITY" "$item"30done < <(find "$APP/Contents" \( -name "*.dylib" -o -name "*.framework" -o -path "*/Helpers/*" \) -not -path "*/Helpers" -print0 | sort -z -r)31codesign --force --timestamp --options runtime --entitlements "$ENT" --sign "$IDENTITY" "$APP"32echo "== verify"33codesign --verify --deep --strict --verbose=2 "$APP"34echo "architectures: $(lipo -archs "$APP/Contents/MacOS/ORIX Sonata")"35codesign -dvv "$APP" 2>&1 | grep -E "^(Identifier|Authority|TeamIdentifier|Timestamp|Runtime Version)" | sed 's/^/  /'36FLAGS="$(codesign -dv "$APP" 2>&1 | sed -n 's/.*flags=\([^ ]*\).*/\1/p')"; echo "flags: $FLAGS"37[[ "$FLAGS" == *runtime* ]] || { echo "ERROR: Hardened Runtime is not enabled." >&2; exit 1; }38if codesign -d --entitlements - --xml "$APP" 2>/dev/null | grep -q "get-task-allow"; then echo "ERROR: get-task-allow present." >&2; exit 1; fi39echo "entitlements: $(codesign -d --entitlements - --xml "$APP" 2>/dev/null | plutil -convert json -o - - 2>/dev/null || echo '{}')"40for h in sonata sonata-lsp; do codesign --verify --strict "$HELPERS/$h" && echo "  helper $h: signed ($(codesign -dv "$HELPERS/$h" 2>&1 | sed -n 's/.*flags=\([^ ]*\).*/\1/p'))"; done41[[ -f "$APP/Contents/Resources/AppIcon.icns" ]] || { echo "ERROR: the app has no icon." >&2; exit 1; }42echo "version: $(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' "$APP/Contents/Info.plist") ($(/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' "$APP/Contents/Info.plist"))"43echo "RESULT: $APP is built and signed. It is NOT notarized yet (Scripts/notarize.sh)."44
Files main
Menu

Theme