diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100755 index 0000000..f7b88fe --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# Build the Release configuration and install Museion.app to /Applications. +set -euo pipefail + +APP_NAME="Museion.app" +PROJECT="Museion.xcodeproj" +SCHEME="Museion" +CONFIGURATION="Release" +DEST="/Applications/$APP_NAME" + +cd "$(dirname "$0")/.." # repo root — PROJECT is relative (same guard as build-and-run.sh) + +echo "Building $CONFIGURATION..." +log=$(mktemp -t museion-deploy) +trap 'rm -f "$log"' EXIT +# Pin destination to avoid the "Using the first of multiple matching destinations" +# warning and to build only this Mac's arch (local self-deploy). +# Incremental by default — opt in to a pristine rebuild with CLEAN=1. +CLEAN_ACTION="" +[[ "${CLEAN:-0}" == "1" ]] && CLEAN_ACTION="clean" +if ! xcodebuild -project "$PROJECT" -scheme "$SCHEME" -configuration "$CONFIGURATION" \ + -destination 'platform=macOS,arch=arm64' -quiet $CLEAN_ACTION build >"$log" 2>&1; then + echo "Build failed:" >&2 + cat "$log" >&2 + exit 1 +fi + +# Resolve where xcodebuild placed the product (DerivedData path is per-machine). +# Same destination as the build so both invocations evaluate identically; +# -skipPackageUpdates skips the SPM resolution pass. +PRODUCTS_DIR=$(xcodebuild -project "$PROJECT" -scheme "$SCHEME" \ + -configuration "$CONFIGURATION" -destination 'platform=macOS,arch=arm64' \ + -skipPackageUpdates -showBuildSettings 2>/dev/null \ + | awk -F'= ' '/BUILT_PRODUCTS_DIR = / {print $2; exit}') +SRC="$PRODUCTS_DIR/$APP_NAME" + +if [[ ! -d "$SRC" ]]; then + echo "Build did not produce $SRC" >&2 + exit 1 +fi + +echo "Deploying: $SRC" +ditto "$SRC" "$DEST" # ditto preserves bundle xattr/resource forks/codesign (cp -R does not) +echo "Installed: $DEST"