Jotley / app · jotley.ai / scripts / build-mac-local.sh
| 1 | #!/bin/zsh |
| 2 | # Permission testing needs a certificate-backed identity that survives rebuilds. |
| 3 | # Ad-hoc/unsigned compile checks can still use the documented xcodebuild command. |
| 4 | set -euo pipefail |
| 5 | if (( $# > 1 )) || [[ -n "${1:-}" && "$1" != --check-signing ]]; then |
| 6 | print -u2 'Usage: scripts/build-mac-local.sh [--check-signing]' |
| 7 | exit 1 |
| 8 | fi |
| 9 | task_repo_root="$(cd "$(dirname "$0")/.." && pwd)" |
| 10 | task_identity="${JOTLEY_MAC_SIGNING_IDENTITY:?Set JOTLEY_MAC_SIGNING_IDENTITY to an installed Apple signing certificate name or SHA-1.}" |
| 11 | task_team="${JOTLEY_MAC_SIGNING_TEAM:?Set JOTLEY_MAC_SIGNING_TEAM to the certificate's Apple team ID.}" |
| 12 | task_configuration="${JOTLEY_MAC_CONFIGURATION:-Release}" |
| 13 | task_derived_data="${JOTLEY_MAC_DERIVED_DATA:-/Volumes/Expand/Codex Media/jotley-local-signed-build}" |
| 14 | task_keychain="$HOME/Library/Keychains/login.keychain-db" |
| 15 | if [[ "$task_identity" == '-' || "$task_configuration" != (Debug|Release) ]]; then |
| 16 | print -u2 'Use an Apple certificate and Debug or Release; ad-hoc signing cannot preserve privacy grants across changed builds.' |
| 17 | exit 1 |
| 18 | fi |
| 19 | task_identity="$(python3 "$task_repo_root/scripts/signing_identity.py" "$task_identity")" |
| 20 | if [[ "${1:-}" == --check-signing ]]; then |
| 21 | print "Signing preflight passed using login keychain: $task_identity" |
| 22 | exit 0 |
| 23 | fi |
| 24 | if [[ ! -d /Volumes/Expand ]]; then |
| 25 | print -u2 'Expand is not mounted. Mount it before building; generated files must stay on Expand.' |
| 26 | exit 1 |
| 27 | fi |
| 28 | export TMPDIR="/Volumes/Expand/Scratch/codex-media-jotley-local-signed-build-tmp" |
| 29 | mkdir -p "$TMPDIR" |
| 30 | xcodebuild -project "$task_repo_root/Jotley.xcodeproj" -scheme Jotley \ |
| 31 | -configuration "$task_configuration" -destination 'platform=macOS' \ |
| 32 | -derivedDataPath "$task_derived_data" CODE_SIGN_STYLE=Manual \ |
| 33 | CODE_SIGNING_ALLOWED=YES CODE_SIGN_IDENTITY="$task_identity" \ |
| 34 | OTHER_CODE_SIGN_FLAGS="--keychain \"$task_keychain\"" \ |
| 35 | DEVELOPMENT_TEAM="$task_team" build |
| 36 | task_app="$task_derived_data/Build/Products/$task_configuration/Jotley.app" |
| 37 | codesign --verify --strict "$task_app" |
| 38 | task_signature="$(codesign -dv --verbose=4 "$task_app" 2>&1)" |
| 39 | if [[ "$task_signature" != *"TeamIdentifier=$task_team"* || "$task_signature" == *'Signature=adhoc'* ]]; then |
| 40 | print -u2 'The app does not have the requested stable Apple signing identity. Do not use it for permission testing.' |
| 41 | exit 1 |
| 42 | fi |
| 43 | print "Signed local app: $task_app" |
| 44 | codesign -dr - "$task_app" |