Add IPA build and deploy script for shared distribution server
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 <noreply@anthropic.com>
This commit is contained in:
100
scripts/ipa-server/build-and-deploy.sh
Executable file
100
scripts/ipa-server/build-and-deploy.sh
Executable file
@@ -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
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>method</key>
|
||||
<string>${EXPORT_METHOD}</string>
|
||||
<key>signingStyle</key>
|
||||
<string>automatic</string>
|
||||
<key>teamID</key>
|
||||
<string>AE5DZKJHGN</string>
|
||||
<key>compileBitcode</key>
|
||||
<false/>
|
||||
<key>stripSwiftSymbols</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
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
|
||||
Reference in New Issue
Block a user