Repository Public
1#!/usr/bin/env bash2# SP Chat iOS3# File: Scripts/release.sh4# Description: Release archive, App Store Connect signing (automatic, team API key already on this Mac), IPA export, optional TestFlight upload.5# usage: release.sh archive | export | upload | all6#7# Author: Simon-Pierre Boucher8# Contact: contact@spboucher.ai9set -euo pipefail10cd "$(dirname "$0")/.."11KEY_ID="${ASC_KEY_ID:-L379BDKR69}"12ISSUER="${ASC_ISSUER_ID:-013e761f-e05c-4d93-a50b-f3d960adae4a}"13KEY="$HOME/.appstoreconnect/private_keys/AuthKey_${KEY_ID}.p8"14AUTH=(-allowProvisioningUpdates -authenticationKeyPath "$KEY" -authenticationKeyID "$KEY_ID" -authenticationKeyIssuerID "$ISSUER")15ARCHIVE="build/SPChat.xcarchive"16mkdir -p build/logs dist17step="${1:-all}"1819if [[ "$step" == archive || "$step" == all ]]; then20 Scripts/build.sh generate21 rm -rf "$ARCHIVE"22 xcodebuild -project SPChat.xcodeproj -scheme SPChat -configuration Release -destination "generic/platform=iOS" \23 -archivePath "$ARCHIVE" -derivedDataPath build/DerivedData-release "${AUTH[@]}" archive > build/logs/archive.log 2>&1 \24 || { grep -E "error:|\*\* " build/logs/archive.log | sort -u | head -20; exit 1; }25 APP="$ARCHIVE/Products/Applications/SPChat.app"26 echo "archive : $(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Info.plist") ($(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$APP/Info.plist"))"27fi2829if [[ "$step" == export || "$step" == all ]]; then30 rm -rf dist/export31 xcodebuild -exportArchive -archivePath "$ARCHIVE" -exportOptionsPlist Scripts/ExportOptions.plist -exportPath dist/export "${AUTH[@]}" > build/logs/export.log 2>&1 \32 || { grep -E "error:|\*\* " build/logs/export.log | sort -u | head -20; exit 1; }33 ls -lh dist/export/*.ipa34fi3536if [[ "$step" == upload ]]; then37 # altool looks for the key in ~/.appstoreconnect/private_keys ; it validates then uploads to App Store Connect (TestFlight)38 xcrun altool --upload-app -f "dist/export/SP Chat.ipa" -t ios --apiKey "$KEY_ID" --apiIssuer "$ISSUER" 2>&1 | tee build/logs/upload.log | tail -1539fi40