Repository Public License
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : ORIX Camera8# File : Scripts/release.sh9# Description : Release archive, App Store Connect export, validation and10# TestFlight upload. usage: release.sh archive | export |11# validate | upload The App Store Connect API key is read12# from the environment or from ~/.config/orix-camera/asc.env13# (ASC_KEY_ID, ASC_ISSUER_ID; the .p8 stays in14# ~/.appstoreconnect/private_keys). Nothing secret lives in15# this repository. `upload` sends a build to Apple: run it16# only with the owner's explicit authorization.17# Module : Scripts18# Repository : https://git.spboucher.ai/orix-camera19# Project Website : https://www.orixlab.dev20# Created : 2026-11-2121# Last Modified : 2026-11-2122#23# Author : Simon-Pierre Boucher24# Position : Professor of Finance25# Institution : Université du Québec en Outaouais (UQO)26# Organization : SP Boucher27# Website : https://spboucher.ai28# Git : https://git.spboucher.ai29#30# Preferred Contact: support@spboucher.ai31# Technical Contact: dev@spboucher.ai32# Security/Admin : admin@spboucher.ai33#34# Copyright (c) 202635# Simon-Pierre Boucher36# All rights reserved where applicable. This file is governed by the37# applicable project license, copyright notices and relevant law.38# Existing third-party rights and notices remain unaffected.39#40# License : Proprietary, all rights reserved (see license file)41# License File : LICENSE42#43# Do not embed credentials, private keys, access tokens,44# certificates or confidential personal information.45#46# =============================================================================47# END OF SP BOUCHER SOURCE HEADER48# =============================================================================4950set -euo pipefail51cd "$(dirname "$0")/.."52[[ -f "$HOME/.config/orix-camera/asc.env" ]] && source "$HOME/.config/orix-camera/asc.env"53ARCHIVE="build/ORIXCamera.xcarchive"54IPA="dist/export/ORIX Camera.ipa"55mkdir -p build/logs dist56step="${1:-}"5758need_key() {59 : "${ASC_KEY_ID:?set ASC_KEY_ID (App Store Connect API key id)}"60 : "${ASC_ISSUER_ID:?set ASC_ISSUER_ID (App Store Connect issuer id)}"61 KEY="$HOME/.appstoreconnect/private_keys/AuthKey_${ASC_KEY_ID}.p8"62 [[ -f "$KEY" ]] || { echo "missing $KEY"; exit 1; }63 AUTH=(-allowProvisioningUpdates -authenticationKeyPath "$KEY" -authenticationKeyID "$ASC_KEY_ID" -authenticationKeyIssuerID "$ASC_ISSUER_ID")64}6566case "$step" in67 archive)68 Scripts/build.sh generate69 rm -rf "$ARCHIVE"70 # Signed with the Apple ID account configured in Xcode (automatic signing registers the App ID if needed).71 xcodebuild -project ORIXCamera.xcodeproj -scheme ORIXCamera -configuration Release -destination "generic/platform=iOS" \72 -archivePath "$ARCHIVE" -derivedDataPath build/DerivedData-release -allowProvisioningUpdates archive > build/logs/archive.log 2>&1 \73 || { grep -E "error:|\*\* " build/logs/archive.log | sort -u | head -20; exit 1; }74 APP="$ARCHIVE/Products/Applications/ORIXCamera.app"75 echo "archive: $(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Info.plist") ($(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$APP/Info.plist"))"76 codesign -dv "$APP" 2>&1 | grep -E "Identifier|TeamIdentifier|Authority" | head -4 ;;77 export)78 need_key79 rm -rf dist/export80 xcodebuild -exportArchive -archivePath "$ARCHIVE" -exportOptionsPlist Scripts/ExportOptions.plist -exportPath dist/export "${AUTH[@]}" > build/logs/export.log 2>&1 \81 || { grep -E "error:|\*\* " build/logs/export.log | sort -u | head -20; exit 1; }82 ls -lh dist/export/*.ipa ;;83 validate)84 need_key85 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 ;;86 upload)87 need_key88 [[ "${ORIX_UPLOAD_AUTHORIZED:-}" == "yes" ]] || { echo "refusing to upload: set ORIX_UPLOAD_AUTHORIZED=yes once the owner has authorized this build"; exit 3; }89 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 ;;90 *) echo "usage: release.sh archive | export | validate | upload"; exit 2 ;;91esac92