SPB Git

Repository Public

release.sh 3.3 KB 47 lines shellscript

1#!/bin/bash2# ORIX Docs3# File: Scripts/release.sh4# Description: Builds the Release configuration with the hardened runtime, signs it with the Developer ID Application identity already in5#              the keychain (bundled command-line tool included) and verifies the result. Produces dist/ORIX Docs.app.6#              Nothing is uploaded here; see Scripts/notarize.sh.7#8# Author: Simon-Pierre Boucher9# Contact: contact@spboucher.ai10set -euo pipefail11cd "$(dirname "$0")/.."12DD="build/DerivedData"; APP="dist/ORIX Docs.app"13IDENTITY="$(security find-identity -v -p codesigning | sed -n 's/.*"\(Developer ID Application: [^"]*\)".*/\1/p' | head -1)"14[[ -n "$IDENTITY" ]] || { echo "ERROR: no Developer ID Application identity in the keychain." >&2; exit 1; }15xcodegen generate --quiet16echo "== Building Release (signing as: $IDENTITY) =="17rm -rf "$DD/Build/Products/Release/ORIX Docs.app"18xcodebuild -project ORIXDocs.xcodeproj -scheme ORIXDocs -derivedDataPath "$DD" -configuration Release build 2>&1 \19  | sed 's/\x1b\[[0-9;]*m//g' | grep -E "^/.*: error:|error:|\*\* BUILD" | grep -vE "DVT|CoreSimulator|CoreDevice" | sort -u || true20BUILT="$DD/Build/Products/Release/ORIX Docs.app"21[[ -d "$BUILT" ]] || { echo "ERROR: Release build failed." >&2; exit 1; }22rm -rf dist && mkdir -p dist23ditto "$BUILT" "$APP"2425if grep -q 'name: "orixdocs"' Packages/ORIXDocsKit/Package.swift; then26  echo "== Building and embedding the command-line tool =="27  (cd Packages/ORIXDocsKit && swift build -c release --product orixdocs --arch arm64 --arch x86_64 --scratch-path /tmp/orixdocs-release 2>&1 | grep -E "error|Compiling|Build complete" | tail -2)28  TOOL="$(cd Packages/ORIXDocsKit && swift build -c release --product orixdocs --arch arm64 --arch x86_64 --scratch-path /tmp/orixdocs-release --show-bin-path)/orixdocs"29  mkdir -p "$APP/Contents/Helpers"30  cp "$TOOL" "$APP/Contents/Helpers/orixdocs"31  # SwiftPM resource bundles the tool needs (math fonts) sit next to it.32  for b in "$(dirname "$TOOL")"/*.bundle; do [[ -d "$b" ]] && ditto "$b" "$APP/Contents/Helpers/$(basename "$b")"; done33  find "$APP/Contents/Helpers" -name "*.bundle" -maxdepth 1 -exec codesign --force --timestamp --sign "$IDENTITY" {} \;34  codesign --force --timestamp --options runtime --identifier ai.spboucher.orix.docs.cli --sign "$IDENTITY" "$APP/Contents/Helpers/orixdocs"35  # The bundle changed: sign it again (same entitlements).36  codesign --force --timestamp --options runtime --entitlements App/Resources/ORIXDocs.entitlements --sign "$IDENTITY" "$APP"37fi3839echo "== Verifying =="40codesign --verify --deep --strict --verbose=2 "$APP"41echo "-- architectures: $(lipo -archs "$APP/Contents/MacOS/ORIX Docs")"42echo "-- signature:"; codesign -dvv "$APP" 2>&1 | grep -E "^(Identifier|Authority|TeamIdentifier|Timestamp|Runtime Version)" | sed 's/^/   /'43echo "-- flags: $(codesign -dv "$APP" 2>&1 | sed -n 's/.*flags=\([^ ]*\).*/\1/p')"44if codesign -d --entitlements - --xml "$APP" 2>/dev/null | grep -q "get-task-allow"; then echo "ERROR: get-task-allow present; not distributable." >&2; exit 1; fi45echo "-- version: $(/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' "$APP/Contents/Info.plist") ($(/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' "$APP/Contents/Info.plist"))"46echo "RESULT: $APP is built and signed. It is NOT notarized yet (run Scripts/notarize.sh)."47
Files main
Menu

Theme