tv-anarchy/build-install.sh

56 lines
2.5 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Build TVAnarchy (Release) and install it to the OS-appropriate Applications
# folder (see resolve_dest), so the running app and the built app can't silently
# drift. The one irreducible manual step is quitting + relaunching — you can't
# hot-swap a running native app — and the sidebar build stamp
# (v<ver> · <sha> · <time>) makes a stale copy obvious.
set -euo pipefail
cd "$(dirname "$0")"
# Per-OS install logic lives in ONE place: tools/platform.sh.
. tools/platform.sh
[ "$(tva_os)" = mac ] || { echo "✗ the build box is macOS-only (xcodebuild); this is $(tva_os)." >&2; exit 1; }
# Default DD lives in the repo (build/dd); tools/release.sh overrides it with an
# ephemeral tmp dir so a release cut never churns the working build cache.
DD="${TVANARCHY_DD:-build/dd}"
APP="$DD/Build/Products/Release/TVAnarchy.app"
DEST="$(tva_resolve_dest mac)"
echo "→ stamp build identity (git SHA / time → BuildStamp.swift)"
tools/stamp-build.sh
echo "→ xcodegen generate"
xcodegen generate >/dev/null
echo "→ xcodebuild (Release)"
xcodebuild -scheme TVAnarchy -configuration Release -derivedDataPath "$DD" \
build CODE_SIGNING_ALLOWED=NO 2>&1 | grep -E "Stamp version|stamped:|BUILD SUCCEEDED|BUILD FAILED|error:" || true
[ -d "$APP" ] || { echo "✗ build produced no app at $APP" >&2; exit 1; }
mkdir -p "$(dirname "$DEST")"
rm -rf "$DEST"
cp -R "$APP" "$DEST"
# One install location only: drop a stale copy at the other auto candidate so
# the launched app can never silently be an old build. Skipped under an explicit
# TVANARCHY_DEST (e.g. a test install must not touch the real one).
if [ -z "${TVANARCHY_DEST:-}" ]; then
for other in "/Applications/TVAnarchy.app" "$HOME/Applications/TVAnarchy.app"; do
if [ "$other" != "$DEST" ] && [ -d "$other" ]; then
rm -rf "$other" && echo " removed stale copy at $other"
fi
done
fi
# Marketing version is in the plist; SHA / build / time live in the compiled
# BuildStamp constant we just generated (the reliable source — see project.yml).
VER=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$DEST/Contents/Info.plist")
BUILD=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$DEST/Contents/Info.plist")
SHA=$(sed -n 's/.*sha = "\(.*\)"/\1/p' Sources/TVAnarchyCore/BuildStamp.swift)
STAMP=$(sed -n 's/.*buildTime = "\(.*\)"/\1/p' Sources/TVAnarchyCore/BuildStamp.swift)
echo "✓ installed v$VER (build $BUILD) → $DEST"
echo " $SHA · $STAMP"
echo " quit any running TVAnarchy and relaunch to pick this up."