Repository Public
1#!/usr/bin/env bash2# SP Wallet iOS3# File: Scripts/release.sh4# Description: Release archive (signed with the Apple ID account configured in Xcode: App Groups cannot be provisioned with an API5# key), release safety checks, IPA export and TestFlight upload with the team's App Store Connect API key.6# usage: release.sh archive | check | export | upload | all (all = archive + check + export; upload is explicit)7#8# Author: Simon-Pierre Boucher9# Contact: contact@spboucher.ai10set -euo pipefail11cd "$(dirname "$0")/.."12KEY_ID="${ASC_KEY_ID:-L379BDKR69}"13ISSUER="${ASC_ISSUER_ID:-013e761f-e05c-4d93-a50b-f3d960adae4a}"14KEY="$HOME/.appstoreconnect/private_keys/AuthKey_${KEY_ID}.p8"15AUTH=(-allowProvisioningUpdates -authenticationKeyPath "$KEY" -authenticationKeyID "$KEY_ID" -authenticationKeyIssuerID "$ISSUER")16ARCHIVE="build/SPWallet.xcarchive"17APP="$ARCHIVE/Products/Applications/SPWallet.app"18mkdir -p build/logs dist19step="${1:-all}"2021if [[ "$step" == archive || "$step" == all ]]; then22 Scripts/build.sh generate23 [[ -d "$ARCHIVE" ]] && mv "$ARCHIVE" "build/SPWallet-$(date +%s).old.xcarchive"24 xcodebuild -project SPWallet.xcodeproj -scheme SPWallet -configuration Release -destination "generic/platform=iOS" \25 -archivePath "$ARCHIVE" -derivedDataPath build/DerivedData-release -allowProvisioningUpdates archive > build/logs/archive.log 2>&1 \26 || { grep -E "error:|\*\* " build/logs/archive.log | sort -u | head -20; exit 1; }27 echo "archive : $(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Info.plist") ($(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$APP/Info.plist"))"28fi2930if [[ "$step" == check || "$step" == all ]]; then31 Scripts/check-release.sh "$APP"32fi3334if [[ "$step" == export || "$step" == all ]]; then35 [[ -d dist/export ]] && mv dist/export "dist/export-$(date +%s).old"36 xcodebuild -exportArchive -archivePath "$ARCHIVE" -exportOptionsPlist Scripts/ExportOptions.plist -exportPath dist/export "${AUTH[@]}" > build/logs/export.log 2>&1 \37 || { grep -E "error:|\*\* " build/logs/export.log | sort -u | head -20; exit 1; }38 ls -lh dist/export/*.ipa39 # the exported app is the one that ships: check IT, with the distribution requirements40 X="build/ipa-check-$(date +%s)"; mkdir -p "$X"; unzip -q "$(ls dist/export/*.ipa | head -1)" -d "$X"41 Scripts/check-release.sh "$X/Payload/SPWallet.app" --distribution42fi4344if [[ "$step" == upload ]]; then45 IPA=$(ls dist/export/*.ipa | head -1)46 X="build/ipa-check-$(date +%s)"; mkdir -p "$X"; unzip -q "$IPA" -d "$X"47 Scripts/check-release.sh "$X/Payload/SPWallet.app" --distribution48 xcrun altool --upload-app -f "$IPA" -t ios --apiKey "$KEY_ID" --apiIssuer "$ISSUER" 2>&1 | tee build/logs/upload.log | tail -1549fi50