Repository Public
1#!/usr/bin/env bash2# SP Lecture Studio3# File: scripts/archive-ios.sh4# Description: iOS / iPadOS release: archive (automatic signing), App Store Connect export (IPA), optional validation and TestFlight upload.5# iOS apps are code-signed and distributed through App Store Connect; macOS notarization does not apply.6# usage: scripts/archive-ios.sh archive | export | validate | upload | all (all = archive + export)7# The App Store Connect API key is read from ~/.config/splecturestudio/asc.env (ASC_KEY_ID, ASC_ISSUER_ID, ASC_KEY_PATH);8# that file is not part of the repository and is never printed.9#10# Author: Simon-Pierre Boucher11# Contact: contact@spboucher.ai12set -euo pipefail13cd "$(dirname "$0")/.."14ENV="${ASC_ENV:-$HOME/.config/splecturestudio/asc.env}"15[[ -f "$ENV" ]] || { echo "ERROR: $ENV not found (ASC_KEY_ID, ASC_ISSUER_ID, ASC_KEY_PATH)." >&2; exit 1; }16# shellcheck disable=SC109017source "$ENV"18AUTH=(-allowProvisioningUpdates -authenticationKeyPath "$ASC_KEY_PATH" -authenticationKeyID "$ASC_KEY_ID" -authenticationKeyIssuerID "$ASC_ISSUER_ID")19ARCHIVE="build/LectureStudio-iOS.xcarchive"; mkdir -p build/logs dist20step="${1:-all}"21if [[ "$step" == archive || "$step" == all ]]; then22 (cd Apps/LectureStudio && xcodegen generate --quiet)23 rm -rf "$ARCHIVE"24 xcodebuild -project Apps/LectureStudio/LectureStudio.xcodeproj -scheme LectureStudio-iOS -configuration Release -destination "generic/platform=iOS" \25 -archivePath "$ARCHIVE" -derivedDataPath "$HOME/Library/Developer/SPLectureStudio/DerivedData-Release" "${AUTH[@]}" archive > build/logs/archive-ios.log 2>&1 \26 || { grep -E "error:|\*\* " build/logs/archive-ios.log | sort -u | head -20; exit 1; }27 APP="$ARCHIVE/Products/Applications/SP Lecture Studio.app"28 echo "archive : $(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Info.plist") ($(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$APP/Info.plist"))"29fi30if [[ "$step" == export || "$step" == all ]]; then31 rm -rf dist/ios-export32 xcodebuild -exportArchive -archivePath "$ARCHIVE" -exportOptionsPlist scripts/ExportOptions-iOS.plist -exportPath dist/ios-export "${AUTH[@]}" > build/logs/export-ios.log 2>&1 \33 || { grep -E "error:|\*\* " build/logs/export-ios.log | sort -u | head -20; exit 1; }34 ls -lh dist/ios-export/*.ipa35fi36IPA="$(ls dist/ios-export/*.ipa 2>/dev/null | head -1 || true)"37if [[ "$step" == validate ]]; then38 xcrun altool --validate-app -f "$IPA" -t ios --apiKey "$ASC_KEY_ID" --apiIssuer "$ASC_ISSUER_ID" 2>&1 | tee build/logs/validate-ios.log | tail -839fi40if [[ "$step" == upload ]]; then41 # altool looks for the key in ~/.appstoreconnect/private_keys; it validates, then uploads to App Store Connect (TestFlight).42 xcrun altool --upload-app -f "$IPA" -t ios --apiKey "$ASC_KEY_ID" --apiIssuer "$ASC_ISSUER_ID" 2>&1 | tee build/logs/upload-ios.log | tail -1243fi44