SPB Git

Repository Public

release.sh 5.1 KB 88 lines shellscript

1#!/usr/bin/env bash2# =============================================================================3#                  SP BOUCHER | INFRASTRUCTURE & AUTOMATION4#             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project          : SP Search iOS8# File             : Scripts/release.sh9# Description      : Archive, distribution signing, validation, TestFlight10#                    upload and build state. usage: release.sh archive | export11#                    | validate | upload | wait | group | status Signing is12#                    automatic (Xcode's account). Validation, upload and build13#                    state use the team's App Store Connect API key already on14#                    this Mac (~/.appstoreconnect/private_keys/AuthKey_<id>.p8)15#                    — nothing secret lives in the repository. Increment16#                    CURRENT_PROJECT_VERSION in project.yml before each upload.17# Module           : Scripts18# Repository       : https://git.spboucher.ai/sp-search-ios19# Project Website  : https://search.spboucher.ai20# Created          : 2026-12-0121# Last Modified    : 2026-12-0122#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          : None specified (no license file in this repository)41#42# Do not embed credentials, private keys, access tokens,43# certificates or confidential personal information.44#45# =============================================================================46# END OF SP BOUCHER SOURCE HEADER47# =============================================================================4849set -euo pipefail50cd "$(dirname "$0")/.."51KEY_ID="${ASC_KEY_ID:-L379BDKR69}"52ISSUER="${ASC_ISSUER_ID:-013e761f-e05c-4d93-a50b-f3d960adae4a}"53KEY="$HOME/.appstoreconnect/private_keys/AuthKey_${KEY_ID}.p8"54# Since 2.0 the app has an App Group (widget): provisioning one fails with the API key ("Authentication failed"), so55# xcodebuild signs with the Apple ID account of Xcode. SPSEARCH_SIGN_WITH_KEY=1 goes back to the key (no App Group).56AUTH=(-allowProvisioningUpdates)57[ -n "${SPSEARCH_SIGN_WITH_KEY:-}" ] && AUTH+=(-authenticationKeyPath "$KEY" -authenticationKeyID "$KEY_ID" -authenticationKeyIssuerID "$ISSUER")58ARCHIVE=build/SPSearch.xcarchive59APP="$ARCHIVE/Products/Applications/SPSearch.app"60mkdir -p build/logs dist61case "${1:-}" in62archive)63  xcodegen generate --quiet64  rm -rf "$ARCHIVE"65  xcodebuild archive -project SPSearch.xcodeproj -scheme SPSearch -configuration Release -destination "generic/platform=iOS" \66    -archivePath "$ARCHIVE" -derivedDataPath build/dd-release "${AUTH[@]}" > build/logs/archive.log 2>&1 \67    || { grep -E "error:|\*\* " build/logs/archive.log | sort -u | head -20; exit 1; }68  echo "archive: $(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Info.plist") ($(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$APP/Info.plist")) — $(/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$APP/Info.plist")"69  codesign -d --entitlements :- "$APP" 2>/dev/null | plutil -p - | grep -E "application-identifier|get-task-allow" | tr -s ' '70  # Release checks: no debug launch option, no host other than the engine's API in the binary, privacy manifest shipped71  if strings "$APP/SPSearch" | grep -qE "SPQuery|SPStub|SPBaseURL|SPPages|r-stub|etudiants\.example"; then echo "ERROR: debug launch options present in the Release binary"; exit 1; fi72  [ -f "$APP/PrivacyInfo.xcprivacy" ] || { echo "ERROR: privacy manifest missing from the archive"; exit 1; }73  echo "hosts in the binary: $(strings "$APP/SPSearch" | grep -oE "https?://[A-Za-z0-9.-]+" | sort -u | tr '\n' ' ')" ;;74export)75  rm -rf dist/export76  xcodebuild -exportArchive -archivePath "$ARCHIVE" -exportOptionsPlist Scripts/ExportOptions.plist -exportPath dist/export "${AUTH[@]}" > build/logs/export.log 2>&1 \77    || { grep -E "error:|\*\* " build/logs/export.log | sort -u | head -20; exit 1; }78  ls -lh dist/export/*.ipa ;;79validate|upload)80  CMD=--validate-app; [ "$1" = upload ] && CMD=--upload-app81  xcrun altool "$CMD" -f "$(ls dist/export/*.ipa | head -1)" -t ios --apiKey "$KEY_ID" --apiIssuer "$ISSUER" 2>&1 | tee "build/logs/$1.log" | tail -20 ;;82wait|group|status)83  # State of the build on App Store Connect; "group" attaches it to the internal group only (never any review)84  N="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$APP/Info.plist")"85  SPSEARCH_VERSION="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Info.plist")" python3 Scripts/asc.py "$1" "$N" ;;86*) echo "usage: $0 archive|export|validate|upload|wait|group|status"; exit 2 ;;87esac88
Files main
Menu

Theme