SPB Git

Repository Public License

release.sh 3.0 KB 54 lines shellscript

1#!/usr/bin/env bash2# ORIX Scan3# File: Scripts/release.sh4# Description: Release archive, App Store Connect export, validation and TestFlight upload.5#              usage: release.sh archive | export | validate | upload6#              The App Store Connect API key is read from the environment or from ~/.config/orix-scan/asc.env7#              (ASC_KEY_ID, ASC_ISSUER_ID; the .p8 stays in ~/.appstoreconnect/private_keys). Nothing secret lives in this repository.8#              `upload` sends a build to Apple: run it only with the owner's explicit authorization.9#10# Author: Simon-Pierre Boucher11# Contact: contact@spboucher.ai12set -euo pipefail13cd "$(dirname "$0")/.."14[[ -f "$HOME/.config/orix-scan/asc.env" ]] && source "$HOME/.config/orix-scan/asc.env"15ARCHIVE="build/ORIXScan.xcarchive"16IPA="dist/export/ORIX Scan.ipa"17mkdir -p build/logs dist18step="${1:-}"1920need_key() {21  : "${ASC_KEY_ID:?set ASC_KEY_ID (App Store Connect API key id)}"22  : "${ASC_ISSUER_ID:?set ASC_ISSUER_ID (App Store Connect issuer id)}"23  KEY="$HOME/.appstoreconnect/private_keys/AuthKey_${ASC_KEY_ID}.p8"24  [[ -f "$KEY" ]] || { echo "missing $KEY"; exit 1; }25  AUTH=(-allowProvisioningUpdates -authenticationKeyPath "$KEY" -authenticationKeyID "$ASC_KEY_ID" -authenticationKeyIssuerID "$ASC_ISSUER_ID")26}2728case "$step" in29  archive)30    Scripts/build.sh generate31    rm -rf "$ARCHIVE"32    # Signed with the Apple ID account configured in Xcode (automatic signing registers the App ID if needed).33    xcodebuild -project ORIXScan.xcodeproj -scheme ORIXScan -configuration Release -destination "generic/platform=iOS" \34      -archivePath "$ARCHIVE" -derivedDataPath build/DerivedData-release -allowProvisioningUpdates archive > build/logs/archive.log 2>&1 \35      || { grep -E "error:|\*\* " build/logs/archive.log | sort -u | head -20; exit 1; }36    APP="$ARCHIVE/Products/Applications/ORIXScan.app"37    echo "archive: $(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Info.plist") ($(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$APP/Info.plist"))"38    codesign -dv "$APP" 2>&1 | grep -E "Identifier|TeamIdentifier|Authority" | head -4 ;;39  export)40    need_key41    rm -rf dist/export42    xcodebuild -exportArchive -archivePath "$ARCHIVE" -exportOptionsPlist Scripts/ExportOptions.plist -exportPath dist/export "${AUTH[@]}" > build/logs/export.log 2>&1 \43      || { grep -E "error:|\*\* " build/logs/export.log | sort -u | head -20; exit 1; }44    ls -lh dist/export/*.ipa ;;45  validate)46    need_key47    xcrun altool --validate-app -f "$IPA" -t ios --apiKey "$ASC_KEY_ID" --apiIssuer "$ASC_ISSUER_ID" 2>&1 | tee build/logs/validate.log | tail -15 ;;48  upload)49    need_key50    [[ "${ORIX_UPLOAD_AUTHORIZED:-}" == "yes" ]] || { echo "refusing to upload: set ORIX_UPLOAD_AUTHORIZED=yes once the owner has authorized this build"; exit 3; }51    xcrun altool --upload-app -f "$IPA" -t ios --apiKey "$ASC_KEY_ID" --apiIssuer "$ASC_ISSUER_ID" 2>&1 | tee build/logs/upload.log | tail -15 ;;52  *) echo "usage: release.sh archive | export | validate | upload"; exit 2 ;;53esac54
Files main
Menu

Theme