Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : Immo-Ka Admin iOS8# File : Scripts/release.sh9# Description : archive, export, validation et envoi App Store Connect10# (calqué sur celui de Lou-Ka Admin). usage : release.sh11# archive | export | validate | upload | verif-release12# L'archive est signée avec le compte Xcode (signature13# automatique) ; l'export, la validation et l'envoi14# utilisent la clé API App Store Connect déjà présente sur15# ce Mac (~/.appstoreconnect/private_keys). Aucun secret16# dans le dépôt. « verif-release » compile la configuration17# Release pour le simulateur et contrôle le binaire, sans18# rien archiver.19# Module : Scripts20# Repository : https://git.spboucher.ai/immo-ka-admin-ios21# Project Website : https://www.immo-ka.com22# Created : 2026-11-3023# Last Modified : 2026-11-3024#25# Author : Simon-Pierre Boucher26# Position : Professor of Finance27# Institution : Université du Québec en Outaouais (UQO)28# Organization : SP Boucher29# Website : https://spboucher.ai30# Git : https://git.spboucher.ai31#32# Preferred Contact: support@spboucher.ai33# Technical Contact: dev@spboucher.ai34# Security/Admin : admin@spboucher.ai35#36# Copyright (c) 202637# Simon-Pierre Boucher38# All rights reserved where applicable. This file is governed by the39# applicable project license, copyright notices and relevant law.40# Existing third-party rights and notices remain unaffected.41#42# License : None specified (no license file in this repository)43#44# Do not embed credentials, private keys, access tokens,45# certificates or confidential personal information.46#47# =============================================================================48# END OF SP BOUCHER SOURCE HEADER49# =============================================================================5051set -euo pipefail52cd "$(dirname "$0")/.."53KEY_ID="${ASC_KEY_ID:-L379BDKR69}"54ISSUER="${ASC_ISSUER_ID:-013e761f-e05c-4d93-a50b-f3d960adae4a}"55KEY="$HOME/.appstoreconnect/private_keys/AuthKey_${KEY_ID}.p8"56AUTH=(-allowProvisioningUpdates -authenticationKeyPath "$KEY" -authenticationKeyID "$KEY_ID" -authenticationKeyIssuerID "$ISSUER")57ARCHIVE="build/ImmoKaAdmin.xcarchive"58mkdir -p build/logs dist5960# Aucun mécanisme d'essai ne doit survivre dans un binaire Release : ni l'argument du jeton d'essai, ni l'adresse61# de base imposée, ni l'adresse de la préproduction, ni le verrouillage de démonstration.62check_binary() { # chemin de l'exécutable63 local bin="$1" bad=0 dump64 # chaînes et symboles écrits dans un fichier : un « grep -q » en fin de tube ferait échouer le tube (pipefail)65 # et masquerait une chaîne pourtant présente66 dump="$(mktemp)"67 { strings -a "$bin"; nm "$bin" 2>/dev/null || true; } > "$dump"68 # 1. symboles : les fonctions d'essai (#if DEBUG) ne doivent pas exister ; une fonction de production sert de témoin69 if grep -q "signInWithPasskey" "$dump"; then70 for needle in adoptDebugToken debugLock debugUnlock debugSession; do71 if grep -q "$needle" "$dump"; then echo "ERREUR : symbole d'essai « $needle » présent dans le binaire Release"; bad=1; fi72 done73 echo "symboles : témoin de production présent, aucun symbole d'essai"74 else75 echo "symboles : binaire sans table de symboles, contrôle par symboles impossible ici"76 fi77 # 2. chaînes : Swift range les chaînes de 15 octets ou moins dans le code lui-même, où « strings » ne les voit pas ;78 # ce contrôle ne prouve donc rien pour « IKLock » ou « sslip.io », mais il attraperait une adresse d'essai entière79 for needle in IKAdminToken IKBaseURL IMMOKA_BASE_URL immoka-comptes sslip.io; do80 if grep -q "$needle" "$dump"; then echo "ERREUR : « $needle » présent dans le binaire Release"; bad=1; fi81 done82 grep -q "https://www.immo-ka.com" "$dump" || { echo "ERREUR : l'adresse de production est absente du binaire"; bad=1; }83 rm -f "$dump"84 # 3. réglage de compilation : la condition DEBUG ne doit pas être active en Release85 if xcodebuild -project ImmoKaAdmin.xcodeproj -scheme ImmoKaAdmin -configuration Release -showBuildSettings 2>/dev/null | grep "SWIFT_ACTIVE_COMPILATION_CONDITIONS" | grep -qw DEBUG; then86 echo "ERREUR : la condition DEBUG est active en Release"; bad=187 else88 echo "compilation : la condition DEBUG n'est pas active en Release"89 fi90 [ "$bad" = 0 ] && echo "contrôles Release : aucun mécanisme d'essai trouvé, adresse de production présente"91 return "$bad"92}9394case "${1:-}" in95verif-release)96 Scripts/build.sh generate97 xcodebuild -project ImmoKaAdmin.xcodeproj -scheme ImmoKaAdmin -configuration Release -destination "generic/platform=iOS Simulator" \98 -derivedDataPath build/DerivedData-release build > build/logs/verif-release.log 2>&1 || { grep -E "error:|\*\* " build/logs/verif-release.log | sort -u | head -20; exit 1; }99 APP="build/DerivedData-release/Build/Products/Release-iphonesimulator/ImmoKaAdmin.app"100 echo "Release : $(/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")"101 check_binary "$APP/ImmoKaAdmin" ;;102archive)103 Scripts/build.sh generate104 rm -rf "$ARCHIVE"105 xcodebuild -project ImmoKaAdmin.xcodeproj -scheme ImmoKaAdmin -configuration Release -destination "generic/platform=iOS" \106 -archivePath "$ARCHIVE" -derivedDataPath build/DerivedData-release "${AUTH[@]}" archive > build/logs/archive.log 2>&1 \107 || { grep -E "error:|\*\* " build/logs/archive.log | sort -u | head -20; exit 1; }108 APP="$ARCHIVE/Products/Applications/ImmoKaAdmin.app"109 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")"110 codesign -d --entitlements :- "$APP" 2>/dev/null | plutil -p - | grep -E "application-identifier|get-task-allow|associated-domains" -A2 | tr -s ' '111 check_binary "$APP/ImmoKaAdmin" ;;112export)113 rm -rf dist/export114 xcodebuild -exportArchive -archivePath "$ARCHIVE" -exportOptionsPlist Scripts/ExportOptions.plist -exportPath dist/export "${AUTH[@]}" > build/logs/export.log 2>&1 \115 || { grep -E "error:|\*\* " build/logs/export.log | sort -u | head -20; exit 1; }116 ls -lh dist/export/*.ipa ;;117validate|upload)118 CMD=--validate-app; [ "$1" = upload ] && CMD=--upload-app119 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 ;;120*) echo "usage: $0 verif-release|archive|export|validate|upload"; exit 2 ;;121esac122