Repository Public License
1#!/usr/bin/env bash2# ORIX Alarm3# File: Scripts/release.sh4# Description: Release archive, App Store Connect export (automatic signing with the Xcode account on this Mac) and, only on explicit request, TestFlight upload.5# usage: release.sh archive | export | validate | upload6#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"14# App Groups cannot be provisioned with an App Store Connect API key ("Authentication failed"): the archive and the15# export are signed with the Apple ID account configured in Xcode. The API key is only used to validate and upload.16AUTH=(-allowProvisioningUpdates)17ARCHIVE="build/ORIXAlarm.xcarchive"18IPA="dist/export/ORIXAlarm.ipa"19mkdir -p build/logs dist20step="${1:?usage: release.sh archive | export | validate | upload}"2122case "$step" in23archive)24 xcodegen generate --quiet25 rm -rf "$ARCHIVE"26 xcodebuild -project ORIXAlarm.xcodeproj -scheme ORIXAlarm -configuration Release -destination "generic/platform=iOS" \27 -archivePath "$ARCHIVE" -derivedDataPath build/DerivedData-release "${AUTH[@]}" archive > build/logs/archive.log 2>&1 \28 || { grep -E "error:|\*\* " build/logs/archive.log | sort -u | head -20; exit 1; }29 APP="$ARCHIVE/Products/Applications/ORIXAlarm.app"30 echo "archive: $(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Info.plist") ($(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$APP/Info.plist"))"31 ;;32export)33 rm -rf dist/export34 xcodebuild -exportArchive -archivePath "$ARCHIVE" -exportOptionsPlist Scripts/ExportOptions.plist -exportPath dist/export "${AUTH[@]}" > build/logs/export.log 2>&1 \35 || { grep -E "error:|\*\* " build/logs/export.log | sort -u | head -20; exit 1; }36 ls -lh dist/export/*.ipa37 ;;38validate)39 # Validation needs the app record to exist in App Store Connect; it uploads nothing.40 xcrun altool --validate-app -f "$IPA" -t ios --apiKey "$KEY_ID" --apiIssuer "$ISSUER" 2>&1 | tee build/logs/validate.log | tail -1541 ;;42upload)43 # Uploads the exported build to App Store Connect (TestFlight).44 xcrun altool --upload-app -f "$IPA" -t ios --apiKey "$KEY_ID" --apiIssuer "$ISSUER" 2>&1 | tee build/logs/upload.log | tail -1545 ;;46*) echo "unknown step: $step"; exit 2 ;;47esac48