Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | SOFTWARE & RESEARCH4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : Groupe Ka — app iOS native8# File : Scripts/release.sh9# Module : Scripts10# Repository : https://git.spboucher.ai/groupe-ka-ios11# Project Website : Not specified12# Created : 2026-12-0313# Last Modified : 2026-12-0314#15# Author : Simon-Pierre Boucher16# Position : Professor of Finance17# Institution : Université du Québec en Outaouais (UQO)18# Organization : SP Boucher19# Website : https://spboucher.ai20# Git : https://git.spboucher.ai21#22# Preferred Contact: contact@spboucher.ai23# Development : dev@spboucher.ai24# Support : support@spboucher.ai25# Security/Admin : admin@spboucher.ai26#27# Copyright (c) 202628# Simon-Pierre Boucher29# All rights reserved where applicable. This file is governed by the30# applicable project license, copyright notices and relevant law.31# Existing third-party rights and notices remain unaffected.32#33# License : None specified (no license file in this repository)34#35# Do not embed credentials, private keys, access tokens,36# certificates or confidential personal information.37#38# =============================================================================39# END OF SP BOUCHER SOURCE HEADER40# =============================================================================4142# Archive, export, validation et envoi App Store Connect (TestFlight, essais internes seulement).43# usage : release.sh archive | export | record | validate | upload | wait | group | testflight44# L'archive est signée avec le compte Xcode (signature automatique) ; l'export, la validation et l'envoi utilisent45# la clé API App Store Connect déjà présente sur ce Mac (~/.appstoreconnect/private_keys). Aucun secret dans le dépôt.46# Recette reprise des apps sœurs (Food-Ka iOS v2).47set -euo pipefail48cd "$(dirname "$0")/.."49KEY_ID="${ASC_KEY_ID:-L379BDKR69}"50ISSUER="${ASC_ISSUER_ID:-013e761f-e05c-4d93-a50b-f3d960adae4a}"51KEY="$HOME/.appstoreconnect/private_keys/AuthKey_${KEY_ID}.p8"52AUTH=(-allowProvisioningUpdates -authenticationKeyPath "$KEY" -authenticationKeyID "$KEY_ID" -authenticationKeyIssuerID "$ISSUER")53ARCHIVE="build/GroupeKa.xcarchive"54mkdir -p build/logs dist55case "${1:-}" in56archive)57 Scripts/build.sh generate58 rm -rf "$ARCHIVE"59 xcodebuild -project GroupeKa.xcodeproj -scheme GroupeKa -configuration Release -destination "generic/platform=iOS" \60 -archivePath "$ARCHIVE" -derivedDataPath build/DerivedData-release "${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/GroupeKa.app"63 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")"64 codesign -d --entitlements :- "$APP" 2>/dev/null | plutil -p - | grep -E "application-identifier|get-task-allow|associated-domains" -A1 | tr -s ' '65 # aucun réglage de développement ne doit survivre dans un binaire Release66 if /usr/libexec/PlistBuddy -c 'Print :NSAppTransportSecurity:NSAllowsLocalNetworking' "$APP/Info.plist" | grep -q true; then echo "ERREUR : réseau local autorisé en Release"; exit 1; fi67 if strings "$APP/GroupeKa" | grep -q "GK_FIXTURES_DIR\|GK_BASE_URL"; then echo "ERREUR : réglages de test présents dans le binaire Release"; exit 1; fi68 [ -d "$APP/PlugIns/GroupeKaWidget.appex" ] || { echo "ERREUR : widget absent de l'archive"; exit 1; }69 echo "contrôles Release : ATS strict, aucun réglage de test, widget présent" ;;70export)71 rm -rf dist/export72 xcodebuild -exportArchive -archivePath "$ARCHIVE" -exportOptionsPlist Scripts/ExportOptions.plist -exportPath dist/export "${AUTH[@]}" > build/logs/export.log 2>&1 \73 || { grep -E "error:|\*\* " build/logs/export.log | sort -u | head -20; exit 1; }74 ls -lh dist/export/*.ipa ;;75validate|upload)76 CMD=--validate-app; [ "$1" = upload ] && CMD=--upload-app77 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 ;;78record)79 # la fiche App Store Connect est créée une fois dans App Store Connect (voir docs/RELEASE.md) : elle est retrouvée par l'API80 python3 Scripts/asc.py app ;;81wait) python3 Scripts/asc.py wait "$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$ARCHIVE/Products/Applications/GroupeKa.app/Info.plist")" ;;82group) python3 Scripts/asc.py group ;;83testflight)84 # chaîne complète après archive + export : fiche, validation, envoi, traitement, groupe interne.85 # Rien n'est soumis à la revue bêta externe ni à l'App Store ; aucun lien public n'est créé.86 "$0" record && "$0" validate && grep -q "VERIFY SUCCEEDED" build/logs/validate.log \87 && "$0" upload && grep -q "UPLOAD SUCCEEDED" build/logs/upload.log && "$0" wait && "$0" group ;;88*) echo "usage: $0 archive|export|record|validate|upload|wait|group|testflight"; exit 2 ;;89esac90