SPB Git

Repository Public

build-release.sh 3.6 KB 60 lines shellscript

1#!/usr/bin/env bash2# Builds a Release archive of SP Browser signed with a Developer ID Application identity3# (direct distribution outside the Mac App Store) and exports dist/SPBrowser.app.4#5# Usage: scripts/build-release.sh6# Environment:7#   SIGN_IDENTITY   full name of the Developer ID Application identity (default: first one found in the keychain)8#   TEAM_ID         Apple Developer team id (default: read from the identity name)9# Nothing secret is printed: only the identity's display name.10set -euo pipefail11cd "$(dirname "$0")/.."12ROOT="$PWD"13LOG="$ROOT/build/release-build.log"14mkdir -p build dist1516if [[ -z "${SIGN_IDENTITY:-}" ]]; then17  SIGN_IDENTITY="$(security find-identity -v -p codesigning | sed -n 's/.*"\(Developer ID Application: [^"]*\)".*/\1/p' | head -1)"18fi19if [[ -z "$SIGN_IDENTITY" ]]; then20  echo "ERROR: no 'Developer ID Application' identity in the keychain. A Development or Mac App Store identity cannot be used for direct distribution." >&221  exit 122fi23TEAM_ID="${TEAM_ID:-$(sed -n 's/.*(\([A-Z0-9]\{10\}\)).*/\1/p' <<<"$SIGN_IDENTITY")}"24echo "Signing identity : $SIGN_IDENTITY"25echo "Team             : $TEAM_ID"2627# The Developer ID provisioning profile carries the restricted entitlement com.apple.developer.associated-domains28# (passkeys for browser.spboucher.ai). Create or refresh it with scripts/provision.py.29PROFILE_SRC="$ROOT/build/SPBrowser_Developer_ID.provisionprofile"30[[ -f "$PROFILE_SRC" ]] || { echo "ERROR: $PROFILE_SRC missing (run scripts/provision.py)." >&2; exit 1; }31PLIST="$(mktemp)"; security cms -D -i "$PROFILE_SRC" > "$PLIST" 2>/dev/null32PROFILE_UUID="$(/usr/libexec/PlistBuddy -c 'Print :UUID' "$PLIST")"; PROFILE_NAME="$(/usr/libexec/PlistBuddy -c 'Print :Name' "$PLIST")"33PROFILE_EXPIRES="$(/usr/libexec/PlistBuddy -c 'Print :ExpirationDate' "$PLIST")"; rm -f "$PLIST"34for d in "$HOME/Library/Developer/Xcode/UserData/Provisioning Profiles" "$HOME/Library/MobileDevice/Provisioning Profiles"; do mkdir -p "$d"; cp "$PROFILE_SRC" "$d/$PROFILE_UUID.provisionprofile"; done35echo "Profile          : $PROFILE_NAME ($PROFILE_UUID), expires $PROFILE_EXPIRES"3637command -v xcodegen >/dev/null && xcodegen generate --quiet38ARCHIVE="$ROOT/build/SPBrowser.xcarchive"39rm -rf "$ARCHIVE" "$ROOT/dist/SPBrowser.app"4041echo "Archiving (log: build/release-build.log)…"42if ! xcodebuild -project SPBrowser.xcodeproj -scheme SPBrowser -configuration Release \43    -derivedDataPath build/DerivedData-Release -destination 'generic/platform=macOS' \44    -archivePath "$ARCHIVE" archive \45    CODE_SIGN_STYLE=Manual CODE_SIGN_IDENTITY="$SIGN_IDENTITY" DEVELOPMENT_TEAM="$TEAM_ID" PROVISIONING_PROFILE_SPECIFIER="$PROFILE_NAME" \46    CODE_SIGN_ENTITLEMENTS=SPBrowser/Resources/SPBrowser-Release.entitlements \47    ENABLE_HARDENED_RUNTIME=YES CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO OTHER_CODE_SIGN_FLAGS="--timestamp --options=runtime" \48    ONLY_ACTIVE_ARCH=NO SWIFT_COMPILATION_MODE=wholemodule >"$LOG" 2>&1; then49  grep -E "error:|ARCHIVE FAILED" "$LOG" | head -30 >&250  echo "ERROR: archive failed, see $LOG" >&251  exit 152fi5354ditto "$ARCHIVE/Products/Applications/SPBrowser.app" "$ROOT/dist/SPBrowser.app"55VERSION="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' dist/SPBrowser.app/Contents/Info.plist)"56BUILD="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' dist/SPBrowser.app/Contents/Info.plist)"57echo "Built dist/SPBrowser.app  version $VERSION ($BUILD)  archs: $(lipo -archs dist/SPBrowser.app/Contents/MacOS/SPBrowser)"58codesign --verify --deep --strict --verbose=2 dist/SPBrowser.app 2>&1 | tail -259echo "Next: scripts/verify-release.sh, then scripts/notarize.sh"60
Files main
Menu

Theme