-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtestflight_upload.sh
More file actions
100 lines (70 loc) · 2.21 KB
/
testflight_upload.sh
File metadata and controls
100 lines (70 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
set -e
echo "=== TestFlight Upload Script Starting ==="
# Only upload if enabled
if [ "$ENABLE_TESTFLIGHT_UPLOAD" != "TRUE" ]; then
echo "ENABLE_TESTFLIGHT_UPLOAD != TRUE, skipping upload."
exit 0
fi
# Workspace (Unity Cloud Build sets this)
WORKSPACE="${WORKSPACE:-}"
if [ -z "$WORKSPACE" ]; then
echo "ERROR: WORKSPACE environment variable is not set."
exit 1
fi
echo "Workspace: $WORKSPACE"
# ----------------------------
# Locate IPA file
# ----------------------------
IPA_DIR="$WORKSPACE/.build/last/ios-production"
IPA_PATH="$IPA_DIR/build.ipa"
echo "Looking for IPA at: $IPA_PATH"
if [ ! -f "$IPA_PATH" ]; then
echo "IPA not found directly. Searching recursively under workspace..."
IPA_PATH=$(find "$WORKSPACE" -type f -name "*.ipa" | head -n 1)
fi
if [ -z "$IPA_PATH" ]; then
echo "ERROR: No IPA file found anywhere under $WORKSPACE"
exit 1
fi
echo "Using IPA file: $IPA_PATH"
# ----------------------------
# Write the .p8 key to disk
# ----------------------------
if [ -z "$APPSTORE_CONNECT_P8" ]; then
echo "ERROR: APPSTORE_CONNECT_P8 environment variable missing."
exit 1
fi
if [ -z "$APPSTORE_CONNECT_KEY_ID" ]; then
echo "ERROR: APPSTORE_CONNECT_KEY_ID missing."
exit 1
fi
if [ -z "$APPSTORE_CONNECT_ISSUER_ID" ]; then
echo "ERROR: APPSTORE_CONNECT_ISSUER_ID missing."
exit 1
fi
# Replace literal "\n" with real newlines
P8_CONTENT=$(printf "%b" "$APPSTORE_CONNECT_P8")
KEY_DIR="$HOME/.appstoreconnect/private_keys"
KEY_PATH="$KEY_DIR/AuthKey_${APPSTORE_CONNECT_KEY_ID}.p8"
mkdir -p "$KEY_DIR"
echo "Writing App Store Connect private key to:"
echo "$KEY_PATH"
printf "%b" "$P8_CONTENT" > "$KEY_PATH"
# ----------------------------
# Upload using altool
# ----------------------------
echo "Uploading IPA to TestFlight via altool…"
UPLOAD_CMD="xcrun altool --upload-app \
-f \"$IPA_PATH\" \
-t ios \
--apiKey $APPSTORE_CONNECT_KEY_ID \
--apiIssuer $APPSTORE_CONNECT_ISSUER_ID"
echo "Running: $UPLOAD_CMD"
if eval $UPLOAD_CMD; then
echo "=== Upload IPA to Appstore Connect finished successfully ==="
else
echo "=== Upload IPA to Appstore Connect FAILED ==="
exit 1
fi
echo "=== TestFlight Upload Script Completed ==="