Repository Public
1#!/usr/bin/env bash2# =============================================================================3# SP BOUCHER | INFRASTRUCTURE & AUTOMATION4# ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5# =============================================================================6#7# Project : SP Keyboard8# File : Scripts/release.sh9# Description : Archive, checks, export, validation and TestFlight upload10# (internal testing only). usage: release.sh archive |11# verify | export | validate | upload | status | group12# Signing is automatic with Xcode's Apple account (the App13# Group needs it). Validation, upload and build state use14# the team's App Store Connect API key already on this Mac15# (~/.appstoreconnect/private_keys). Nothing secret lives in16# the repository. Increment CURRENT_PROJECT_VERSION in17# project.yml before each upload.18# Module : Scripts19# Repository : https://git.spboucher.ai/sp-keyboard20# 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}"53ARCHIVE=build/SPKeyboard.xcarchive54APP="$ARCHIVE/Products/Applications/SPKeyboard.app"55APPEX="$APP/PlugIns/SPKeyboardExtension.appex"56mkdir -p build/logs dist57plist() { /usr/libexec/PlistBuddy -c "Print :$2" "$1"; }58case "${1:-}" in59archive)60 xcodegen generate --quiet61 rm -rf "$ARCHIVE"62 xcodebuild archive -project SPKeyboard.xcodeproj -scheme SPKeyboard -configuration Release -destination "generic/platform=iOS" \63 -archivePath "$ARCHIVE" -derivedDataPath build/dd-release -allowProvisioningUpdates > build/logs/archive.log 2>&1 \64 || { grep -E "error:|\*\* " build/logs/archive.log | sort -u | head -20; exit 1; }65 echo "archive: $(plist "$APP/Info.plist" CFBundleShortVersionString) ($(plist "$APP/Info.plist" CFBundleVersion))"66 "$0" verify ;;67verify)68 fail=069 [ -d "$APPEX" ] || { echo "ERROR: keyboard extension missing from PlugIns"; exit 1; }70 echo "app: $(plist "$APP/Info.plist" CFBundleIdentifier) — $(plist "$APP/Info.plist" CFBundleDisplayName)"71 echo "extension: $(plist "$APPEX/Info.plist" CFBundleIdentifier) — $(plist "$APPEX/Info.plist" NSExtension:NSExtensionPointIdentifier), RequestsOpenAccess=$(plist "$APPEX/Info.plist" NSExtension:NSExtensionAttributes:RequestsOpenAccess), PrimaryLanguage=$(plist "$APPEX/Info.plist" NSExtension:NSExtensionAttributes:PrimaryLanguage)"72 for bundle in "$APP" "$APPEX"; do73 codesign --verify --strict "$bundle" 2>&1 && echo "signature ok: $(basename "$bundle") — $(codesign -dvv "$bundle" 2>&1 | grep -E "^Authority=" | head -1)"74 ent="$(codesign -d --entitlements :- "$bundle" 2>/dev/null | plutil -convert json -o - - 2>/dev/null || echo '{}')"75 echo " entitlements: $(echo "$ent" | python3 -c "import sys,json; d=json.load(sys.stdin); print({k:d[k] for k in ('application-identifier','com.apple.security.application-groups','keychain-access-groups','get-task-allow') if k in d})")"76 echo "$ent" | grep -q "group.ai.spboucher.keyboard" || { echo " ERROR: App Group entitlement missing"; fail=1; }77 echo "$ent" | grep -q "ai.spboucher.keyboard.shared" || { echo " ERROR: shared keychain group missing"; fail=1; }78 [ "$(plist "$bundle/Info.plist" SPKeychainAccessGroup)" = "3YM54G49SN.ai.spboucher.keyboard.shared" ] || { echo " ERROR: SPKeychainAccessGroup not resolved"; fail=1; }79 done80 [ -f "$APP/PrivacyInfo.xcprivacy" ] || { echo "ERROR: privacy manifest missing from the app"; fail=1; }81 [ -f "$APPEX/PrivacyInfo.xcprivacy" ] || { echo "ERROR: privacy manifest missing from the extension"; fail=1; }82 for lex in fr en es; do [ -f "$APPEX/$lex.lex" ] || { echo "ERROR: $lex.lex missing from the extension"; fail=1; }; done83 [ -f "$APP/Assets.car" ] || { echo "ERROR: asset catalog (icon) missing"; fail=1; }84 # No secret and no debug hook in what ships; the only network host is Anthropic's API.85 if grep -rlaE "sk-ant-[A-Za-z0-9_-]{20,}" "$APP" >/dev/null 2>&1; then echo "ERROR: something that looks like an API key is in the archive"; fail=1; else echo "secrets: none found in the archive"; fi86 if strings "$APP/SPKeyboard" "$APPEX/SPKeyboardExtension" | grep -qE "^-?SP(Screen|InMemory|Panel|Page|Theme)$"; then echo "ERROR: debug launch options present in the Release binaries"; fail=1; fi87 echo "hosts in the binaries: $(strings "$APP/SPKeyboard" "$APPEX/SPKeyboardExtension" | grep -oE "https?://[A-Za-z0-9.-]+" | sort -u | tr '\n' ' ')"88 echo "sizes: app $(du -sh "$APP" | cut -f1), extension $(du -sh "$APPEX" | cut -f1)"89 [ "$fail" = 0 ] && echo "verify: ok" || exit 1 ;;90export)91 rm -rf dist/export92 xcodebuild -exportArchive -archivePath "$ARCHIVE" -exportOptionsPlist Scripts/ExportOptions.plist -exportPath dist/export -allowProvisioningUpdates > build/logs/export.log 2>&1 \93 || { grep -E "error:|\*\* " build/logs/export.log | sort -u | head -20; exit 1; }94 ls -lh dist/export/*.ipa ;;95validate|upload)96 CMD=--validate-app; [ "$1" = upload ] && CMD=--upload-app97 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 ;;98status|group|wait)99 SPK_VERSION="$(plist "$APP/Info.plist" CFBundleShortVersionString)" python3 Scripts/asc.py "$1" "$(plist "$APP/Info.plist" CFBundleVersion)" ;;100*) echo "usage: $0 archive|verify|export|validate|upload|status|wait|group"; exit 2 ;;101esac102