Repository Public MIT
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : ORIX Astra8# File : Scripts/release.sh9# Module : Scripts10# Repository : https://git.spboucher.ai/orix-astra11# Created : 2026-11-2112# Last Modified : 2026-11-2113#14# Author : Simon-Pierre Boucher15# Position : Professor of Finance16# Institution : Université du Québec en Outaouais (UQO)17# Organization : SP Boucher18# Website : https://spboucher.ai19# Git : https://git.spboucher.ai20#21# Preferred Contact: support@spboucher.ai22# Technical Contact: dev@spboucher.ai23# Security/Admin : admin@spboucher.ai24#25# Copyright (c) 202626# Simon-Pierre Boucher27# All rights reserved where applicable. This file is governed by the28# applicable project license, copyright notices and relevant law.29# Existing third-party rights and notices remain unaffected.30#31# License : Proprietary, all rights reserved (see license file)32# License File : LICENSE33#34# Do not embed credentials, private keys, access tokens,35# certificates or confidential personal information.36#37# =============================================================================38# END OF SP BOUCHER SOURCE HEADER39# =============================================================================4041# Usage: Scripts/release.sh archive | export | validate | upload42# Release archive and App Store Connect export with automatic signing (team API key already on this Mac).43# `upload` sends the build to TestFlight and refuses to run unless ASTRA_UPLOAD_AUTHORIZED=yes is set by the owner.44set -euo pipefail45cd "$(dirname "$0")/.."46KEY_ID="${ASC_KEY_ID:-L379BDKR69}"47ISSUER="${ASC_ISSUER_ID:-013e761f-e05c-4d93-a50b-f3d960adae4a}"48KEY="$HOME/.appstoreconnect/private_keys/AuthKey_${KEY_ID}.p8"49AUTH=(-allowProvisioningUpdates -authenticationKeyPath "$KEY" -authenticationKeyID "$KEY_ID" -authenticationKeyIssuerID "$ISSUER")50ARCHIVE="build/ORIXAstra.xcarchive"51IPA="$(ls dist/export/*.ipa 2>/dev/null | head -1)"52mkdir -p build/logs dist53step="${1:?usage: release.sh archive | export | validate | upload}"5455case "$step" in56archive)57 xcodegen generate --quiet58 rm -rf "$ARCHIVE"59 xcodebuild -project ORIXAstra.xcodeproj -scheme ORIXAstra -configuration Release -destination "generic/platform=iOS" \60 -archivePath "$ARCHIVE" -derivedDataPath build/dd-release -skipMacroValidation -skipPackagePluginValidation "${AUTH[@]}" archive > build/logs/archive.log 2>&1 \61 || { grep -E "error:|\*\* " build/logs/archive.log | sort -u | head -20; exit 1; }62 APP="$ARCHIVE/Products/Applications/ORIXAstra.app"63 codesign -d --entitlements - "$APP" 2>/dev/null | grep -E "increased-memory-limit" | sed 's/^[[:space:]]*/entitlement: /' || true64 echo "archive: $(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Info.plist") ($(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$APP/Info.plist"))"65 ;;66export)67 rm -rf dist/export68 xcodebuild -exportArchive -archivePath "$ARCHIVE" -exportOptionsPlist Scripts/ExportOptions.plist -exportPath dist/export "${AUTH[@]}" > build/logs/export.log 2>&1 \69 || { grep -E "error:|\*\* " build/logs/export.log | sort -u | head -20; exit 1; }70 ls -lh dist/export/*.ipa71 ;;72validate)73 # Validation needs the app record to exist in App Store Connect; it uploads nothing.74 xcrun altool --validate-app -f "$IPA" -t ios --apiKey "$KEY_ID" --apiIssuer "$ISSUER" 2>&1 | tee build/logs/validate.log | tail -1575 ;;76upload)77 [[ "${ASTRA_UPLOAD_AUTHORIZED:-}" == "yes" ]] || { echo "upload not authorized: set ASTRA_UPLOAD_AUTHORIZED=yes after the owner's explicit go-ahead"; exit 3; }78 # Uploads the exported build to App Store Connect (TestFlight).79 xcrun altool --upload-app -f "$IPA" -t ios --apiKey "$KEY_ID" --apiIssuer "$ISSUER" 2>&1 | tee build/logs/upload.log | tail -1580 ;;81*) echo "unknown step: $step"; exit 2 ;;82esac83