Repository Public
1#!/bin/bash2# Builds the Release configuration (universal, hardened runtime), signs it with the Developer ID3# Application identity already in the keychain and verifies the result. Produces dist/SP Term.app.4# Nothing is uploaded here; see Scripts/notarize.sh.5set -euo pipefail6cd "$(dirname "$0")/.."7DD="build/DerivedData"8APP="dist/SP Term.app"9command -v xcodegen >/dev/null && xcodegen generate --quiet10IDENTITY="$(security find-identity -v -p codesigning | sed -n 's/.*"\(Developer ID Application: [^"]*\)".*/\1/p' | head -1)"11[[ -n "$IDENTITY" ]] || { echo "ERROR: no Developer ID Application identity in the keychain. A locally signed build is still available with Scripts/build.sh release." >&2; exit 1; }12echo "== Building Release (signing as: $IDENTITY) =="13# The identity comes from the Release configuration of the app target in project.yml; overriding it14# on the command line would also apply to the build-tool targets of Swift packages and fail.15rm -rf "$DD/Build/Products/Release/SP Term.app"16xcodebuild -project SPTerm.xcodeproj -scheme SPTerm -derivedDataPath "$DD" -skipPackagePluginValidation -configuration Release build 2>&1 | sed 's/\x1b\[[0-9;]*m//g' | grep -E "^/.*: error:|error:|\*\* BUILD" | grep -vE "DVT|CoreSimulator|CoreDevice" | sort -u17BUILT="$DD/Build/Products/Release/SP Term.app"18[[ -d "$BUILT" ]] || { echo "ERROR: Release build failed." >&2; exit 1; }19rm -rf dist && mkdir -p dist20ditto "$BUILT" "$APP"21echo "== Verifying =="22codesign --verify --deep --strict --verbose=2 "$APP"23echo "-- architectures: $(lipo -archs "$APP/Contents/MacOS/SP Term")"24echo "-- signature:"; codesign -dvv "$APP" 2>&1 | grep -E "^(Identifier|Authority|TeamIdentifier|Timestamp|Runtime Version|CodeDirectory)" | sed 's/^/ /'25echo "-- flags: $(codesign -dv "$APP" 2>&1 | sed -n 's/.*flags=\([^ ]*\).*/\1/p')"26echo "-- entitlements:"; codesign -d --entitlements - --xml "$APP" 2>/dev/null | plutil -convert json -o - - | sed 's/^/ /'; echo27if codesign -d --entitlements - --xml "$APP" 2>/dev/null | grep -q "get-task-allow"; then28 echo "ERROR: the build carries get-task-allow (debug entitlement); it must not be distributed." >&2; exit 129fi30echo "-- version: $(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' "$APP/Contents/Info.plist") ($(/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' "$APP/Contents/Info.plist"))"31echo "RESULT: $APP is built and signed. It is NOT notarized yet (run Scripts/notarize.sh)."32