Repository Public
1#!/usr/bin/env bash2# Author: Simon-Pierre Boucher — contact@spboucher.ai3# File: Scripts/release.sh4# Description: Builds the Release archive of SP Drive (app + File Provider extension) signed with the EXISTING Developer ID Application identity and the Developer ID provisioning profiles, and exports dist/SP Drive.app.5#6# Usage: Scripts/release.sh7# Nothing secret is printed. No certificate is created: the script fails if no Developer ID Application identity exists.8set -euo pipefail9cd "$(dirname "$0")/.."10ROOT="$PWD"; LOG="$ROOT/Build/release-build.log"; APPNAME="SP Drive"; DD="$HOME/Library/Developer/SPDrive/DerivedData-Release"11mkdir -p Build dist1213IDENTITY="$(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; }15TEAM="$(sed -n 's/.*(\([A-Z0-9]\{10\}\)).*/\1/p' <<<"$IDENTITY")"16echo "Signing identity : $IDENTITY"17echo "Team : $TEAM"1819# the provisioning profiles carry the restricted entitlements (associated domains, keychain group)20for f in SPDrive SPDriveFileProvider; do21 SRC="$ROOT/Build/profiles/$f.provisionprofile"22 [[ -f "$SRC" ]] || { echo "ERROR: $SRC missing (create it with Scripts/provision.py)." >&2; exit 1; }23 PLIST="$(mktemp)"; security cms -D -i "$SRC" > "$PLIST" 2>/dev/null24 UUID="$(/usr/libexec/PlistBuddy -c 'Print :UUID' "$PLIST")"; PNAME="$(/usr/libexec/PlistBuddy -c 'Print :Name' "$PLIST")"; EXPIRES="$(/usr/libexec/PlistBuddy -c 'Print :ExpirationDate' "$PLIST")"; rm -f "$PLIST"25 for d in "$HOME/Library/Developer/Xcode/UserData/Provisioning Profiles" "$HOME/Library/MobileDevice/Provisioning Profiles"; do mkdir -p "$d"; cp "$SRC" "$d/$UUID.provisionprofile"; done26 echo "Profile : $PNAME ($UUID), expires $EXPIRES"27done2829xcodegen generate --quiet30ARCHIVE="$ROOT/Build/SPDrive.xcarchive"31rm -rf "$ARCHIVE" "$ROOT/dist/$APPNAME.app"32echo "Archiving (log: Build/release-build.log)…"33if ! xcodebuild -project SPDrive.xcodeproj -scheme SPDrive -configuration Release -derivedDataPath "$DD" \34 -destination 'generic/platform=macOS' -archivePath "$ARCHIVE" archive DEVELOPMENT_TEAM="$TEAM" >"$LOG" 2>&1; then35 grep -E "error:|ARCHIVE FAILED" "$LOG" | sort -u | head -30 >&236 echo "ERROR: archive failed, see $LOG" >&2; exit 137fi38ditto "$ARCHIVE/Products/Applications/$APPNAME.app" "$ROOT/dist/$APPNAME.app"39APP="dist/$APPNAME.app"40VERSION="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Contents/Info.plist")"; BUILD="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$APP/Contents/Info.plist")"41echo "Built $APP version $VERSION ($BUILD) archs: $(lipo -archs "$APP/Contents/MacOS/$APPNAME")"42codesign --verify --deep --strict --verbose=2 "$APP" 2>&1 | tail -243echo "Next: Scripts/verify-release.sh, then Scripts/notarize.sh"44