From bbda33ad330ab2b93526662f2b400a85ff65b29d Mon Sep 17 00:00:00 2001 From: Krishna Kumar Date: Thu, 21 May 2026 11:58:45 -0500 Subject: [PATCH] Add IPA build and deploy script for shared distribution server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builds a development IPA via xcodebuild (with xcodegen pre-pass) and copies it to the shared Tailscale distribution server at https://krishnas-mac-studio.tail37d544.ts.net:8443 — same server and builds directory used by 1ai. Co-Authored-By: Claude Sonnet 4.6 --- scripts/ipa-server/build-and-deploy.sh | 100 +++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 scripts/ipa-server/build-and-deploy.sh diff --git a/scripts/ipa-server/build-and-deploy.sh b/scripts/ipa-server/build-and-deploy.sh new file mode 100755 index 0000000..2fbfbf7 --- /dev/null +++ b/scripts/ipa-server/build-and-deploy.sh @@ -0,0 +1,100 @@ +#!/bin/bash +# Build an Ad Hoc IPA and copy to the shared distribution server. +# Usage: ./build-and-deploy.sh [branch] +# branch defaults to current branch if not specified + +set -e + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +SERVER_BUILDS_DIR="/Volumes/Next2/hermes-home/1ai/builds" +BUILD_DIR="$SCRIPT_DIR/.build" +ARCHIVE_PATH="$BUILD_DIR/Marks.xcarchive" +EXPORT_PATH="$BUILD_DIR/export" + +REPO_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" + +SCHEME="${SCHEME:-Marks}" +CONFIGURATION="${CONFIGURATION:-Debug}" +EXPORT_METHOD="${EXPORT_METHOD:-development}" + +mkdir -p "$SERVER_BUILDS_DIR" +mkdir -p "$BUILD_DIR" + +cd "$REPO_DIR" +CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) + +if [ -n "$CI" ]; then + COMMIT=$(git rev-parse --short HEAD) + echo "📌 CI mode — building commit: $COMMIT (ref: $CURRENT_BRANCH)" +elif [ -n "$1" ] && [ "$1" != "$CURRENT_BRANCH" ]; then + echo "🔀 Switching from $CURRENT_BRANCH to $1..." + git checkout "$1" + echo "⬇️ Pulling latest $1..." + git pull origin "$1" + COMMIT=$(git rev-parse --short HEAD) + echo "📌 Building commit: $COMMIT on $1" +else + echo "⬇️ Pulling latest $CURRENT_BRANCH..." + git pull origin "$CURRENT_BRANCH" + COMMIT=$(git rev-parse --short HEAD) + echo "📌 Building commit: $COMMIT on $CURRENT_BRANCH" +fi + +echo "⚙️ Generating Xcode project..." +xcodegen generate + +echo "🔨 Building $SCHEME ($CONFIGURATION)..." + +xcodebuild archive \ + -scheme "$SCHEME" \ + -configuration "$CONFIGURATION" \ + -archivePath "$ARCHIVE_PATH" \ + -destination 'generic/platform=iOS' \ + 2>&1 | tee "$BUILD_DIR/archive.log" | tail -20 + +cat > "$BUILD_DIR/ExportOptions.plist" << EOF + + + + + method + ${EXPORT_METHOD} + signingStyle + automatic + teamID + AE5DZKJHGN + compileBitcode + + stripSwiftSymbols + + + +EOF + +echo "📦 Exporting IPA..." +xcodebuild -exportArchive \ + -archivePath "$ARCHIVE_PATH" \ + -exportPath "$EXPORT_PATH" \ + -exportOptionsPlist "$BUILD_DIR/ExportOptions.plist" \ + 2>&1 | tee "$BUILD_DIR/export.log" | tail -20 + +IPA_FILE=$(find "$EXPORT_PATH" -name "*.ipa" | head -1) +if [ -n "$IPA_FILE" ]; then + TIMESTAMP=$(date +%Y%m%d-%H%M%S) + APP_PROPS="$ARCHIVE_PATH/Info.plist" + VERSION=$(/usr/libexec/PlistBuddy -c "Print :ApplicationProperties:CFBundleShortVersionString" "$APP_PROPS") + BUILD=$(/usr/libexec/PlistBuddy -c "Print :ApplicationProperties:CFBundleVersion" "$APP_PROPS") + BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF_NAME:-$(git rev-parse --abbrev-ref HEAD)}}" + BRANCH=$(echo "$BRANCH" | sed 's/[^a-zA-Z0-9._-]/-/g') + + DEST_NAME="Marks-${VERSION}-${BUILD}-${BRANCH}-${TIMESTAMP}.ipa" + cp "$IPA_FILE" "$SERVER_BUILDS_DIR/$DEST_NAME" + + echo "" + echo "✅ Build complete!" + echo " IPA: $SERVER_BUILDS_DIR/$DEST_NAME" + echo " Server: https://krishnas-mac-studio.tail37d544.ts.net:8443" +else + echo "❌ No IPA file found in export" + exit 1 +fi