tv-anarchy/deploy.sh

59 lines
2.5 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# deploy.sh — the one command that updates every app this Mac can reach:
# 1. macOS: build-install.sh (Release → /Applications), then relaunch the app
# if it's running, so "deployed" means "running the new build".
# 2. iOS: build TVAnarchyiOS (Release, automatic signing) and install +
# launch it on the first available paired iPhone. Skipped with a
# note (not an error) when no phone is reachable — the mac install
# above has already happened.
set -euo pipefail
cd "$(dirname "$0")"
echo "══ macOS ══"
./build-install.sh
if pgrep -fq "TVAnarchy.app/Contents/MacOS"; then
echo "→ relaunching TVAnarchy"
osascript -e 'quit app "TVAnarchy"' || true
# Wait for the old instance to actually exit — `open` during the quit races
# LaunchServices into a -609 failure (seen in the wild, not hypothetical).
for _ in $(seq 1 20); do
pgrep -fq "TVAnarchy.app/Contents/MacOS" || break
sleep 0.5
done
open -a /Applications/TVAnarchy.app
fi
echo
echo "══ iOS ══"
# First paired-and-available iPhone's CoreDevice identifier (the UUID column).
udid=$(xcrun devicectl list devices 2>/dev/null \
| awk '/iPhone/ && /available/ { for (i = 1; i <= NF; i++)
if ($i ~ /^[0-9A-F]{8}-[0-9A-F]{4}-/) { print $i; exit } }')
if [ -z "$udid" ]; then
echo " no available paired iPhone; skipping (plug it in / same network, then re-run)"
exit 0
fi
APP=build/dd-ios/Build/Products/Release-iphoneos/TVAnarchyiOS.app
# A previous build's bundle must never be installable after a FAILED build —
# drop it first so the existence check below is meaningful (learned the hard way).
rm -rf "$APP"
echo "→ xcodebuild (Release, device)"
# pipefail (set above) carries xcodebuild's failure through the grep, aborting
# the script (set -e) before any install can happen.
xcodebuild -project TVAnarchy.xcodeproj -scheme TVAnarchyiOS -configuration Release \
-destination 'generic/platform=iOS' -derivedDataPath build/dd-ios \
-allowProvisioningUpdates build 2>&1 \
| grep -E "BUILD SUCCEEDED|BUILD FAILED|error:"
[ -d "$APP" ] || { echo "✗ iOS build produced no app at $APP" >&2; exit 1; }
echo "→ install on iPhone ($udid)"
xcrun devicectl device install app --device "$udid" "$APP" >/dev/null
echo "→ launch"
xcrun devicectl device process launch --device "$udid" local.lilith.TVAnarchyiOS >/dev/null 2>&1 \
|| echo " (launch failed — phone locked? the app IS installed; open it by hand)"
echo "✓ iPhone updated"