This commit is contained in:
Mark Gregory
2026-11-04 15:16:11 +00:00
parent 110840cd38
commit 5bebd30041
13 changed files with 315 additions and 28 deletions
+8 -16
View File
@@ -1,6 +1,7 @@
#!/bin/bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
source "$ROOT/scripts/common.sh"
METHOD=release-testing
PROVISIONING=()
while (($#)); do
@@ -22,6 +23,7 @@ TEAM="${DEVELOPMENT_TEAM:-39R6U3437D}"
BASE="${RELEASE_OUTPUT_DIR:-$ROOT/build/releases}"
mkdir -p "$BASE"
OUTPUT="$(mktemp -d "$BASE/$(date +%Y%m%d-%H%M%S)-$METHOD.XXXXXX")"
DERIVED_DATA="$(mktemp -d "$TARNAX_SCRATCH_ROOT/release-derived.XXXXXX")"
ARCHIVE="$OUTPUT/Tarnax.xcarchive"
EXPORT="$OUTPUT/export"
echo "Release output: $OUTPUT"
@@ -34,7 +36,7 @@ with open(sys.argv[1], 'wb') as f:
PY
xcodebuild -project "$ROOT/Tarnax.xcodeproj" -scheme Tarnax \
-configuration Release -destination 'generic/platform=iOS' \
-derivedDataPath "$OUTPUT/DerivedData" -archivePath "$ARCHIVE" \
-derivedDataPath "$DERIVED_DATA" -archivePath "$ARCHIVE" \
DEVELOPMENT_TEAM="$TEAM" CODE_SIGN_STYLE=Automatic \
${PROVISIONING[@]+"${PROVISIONING[@]}"} archive 2>&1 | tee "$OUTPUT/archive.log"
xcodebuild -exportArchive -archivePath "$ARCHIVE" -exportPath "$EXPORT" \
@@ -42,27 +44,17 @@ xcodebuild -exportArchive -archivePath "$ARCHIVE" -exportPath "$EXPORT" \
${PROVISIONING[@]+"${PROVISIONING[@]}"} 2>&1 | tee "$OUTPUT/export.log"
IPA="$EXPORT/Tarnax.ipa"
[[ -f "$IPA" ]] || { echo 'Export finished without Tarnax.ipa' >&2; exit 1; }
VERIFY="$(mktemp -d "$OUTPUT/verify.XXXXXX")"
VERIFY="$(mktemp -d "$TARNAX_SCRATCH_ROOT/verify.XXXXXX")"
trap 'rm -rf "$VERIFY"' EXIT
unzip -q "$IPA" -d "$VERIFY"
APP="$VERIFY/Payload/Tarnax.app"
codesign --verify --deep --strict "$APP"
[[ -f "$APP/embedded.mobileprovision" ]] || { echo 'No embedded provisioning profile' >&2; exit 1; }
security cms -D -i "$APP/embedded.mobileprovision" > "$VERIFY/profile.plist"
python3 - "$APP/Info.plist" "$VERIFY/profile.plist" "$METHOD" <<'PY'
import plistlib, sys, datetime
with open(sys.argv[1],'rb') as f: app=plistlib.load(f)
with open(sys.argv[2],'rb') as f: profile=plistlib.load(f)
assert app['CFBundleIdentifier']=='net.absdev.Tarnax', 'Unexpected app identifier'
assert profile.get('ProvisionedDevices'), 'Profile does not include registered devices'
assert profile['ExpirationDate']>datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None), 'Profile expired'
assert profile['Entitlements']['application-identifier'].endswith('.'+app['CFBundleIdentifier']), 'Profile/app mismatch'
if sys.argv[3]=='release-testing':
assert not profile['Entitlements'].get('get-task-allow',False), 'Distribution IPA has debugging enabled'
print('Verified:', app['CFBundleDisplayName'], app['CFBundleShortVersionString'], 'build', app['CFBundleVersion'])
print('Registered devices:',len(profile['ProvisionedDevices']))
print('Profile expiry:',profile['ExpirationDate'].isoformat()+'Z')
PY
PROFILE_FLAGS=()
if [[ "$METHOD" == release-testing ]]; then PROFILE_FLAGS=(--distribution); fi
python3 "$ROOT/scripts/verify_profile.py" "$APP/Info.plist" "$VERIFY/profile.plist" ${PROFILE_FLAGS[@]+"${PROFILE_FLAGS[@]}"}
(cd "$EXPORT" && shasum -a 256 Tarnax.ipa > Tarnax.ipa.sha256)
echo "Verified IPA: $IPA"
echo "SHA-256: $EXPORT/Tarnax.ipa.sha256"