Skip to content

Commit a7adeb7

Browse files
katipallyCopilot
andcommitted
fix(ci): write .p8 API key as raw text, read APPLE_TEAM_ID from secrets
Two bugs that caused the TestFlight upload to fail immediately: 1. APP_STORE_CONNECT_PRIVATE_KEY was piped through base64 --decode but it's a plain text PEM file, not base64-encoded. macOS base64 gives 'stdin: (null): error' when the input contains PEM headers. Fixed: use printf '%s' directly, no decode step. 2. APPLE_TEAM_ID was read via vars.APPLE_TEAM_ID (Actions Variables) but the secret is stored under Secrets, so the value was always empty. Fixed: reference as secrets.APPLE_TEAM_ID everywhere. Also added early-exit validation so empty secrets fail fast with a clear error message instead of a cryptic build failure 10 min later. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 413e2e9 commit a7adeb7

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

.github/workflows/ios-testflight.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ name: iOS TestFlight
99
# Required repository secrets (Settings → Secrets and variables → Actions):
1010
# APP_STORE_CONNECT_KEY_ID — App Store Connect API key ID (10 chars)
1111
# APP_STORE_CONNECT_ISSUER_ID — App Store Connect issuer UUID
12-
# APP_STORE_CONNECT_PRIVATE_KEY — Base64-encoded contents of AuthKey_xxx.p8
12+
# APP_STORE_CONNECT_PRIVATE_KEY — Raw text contents of AuthKey_xxx.p8 (paste the full file, including BEGIN/END lines)
1313
# IOS_DISTRIBUTION_CERTIFICATE — Base64-encoded Apple Distribution .p12
1414
# IOS_DISTRIBUTION_CERT_PASSWORD — Password for the .p12 above
1515
# IOS_KEYCHAIN_PASSWORD — Throwaway password for the runner keychain
16-
#
17-
# Required repository variables (Settings → Secrets and variables → Actions → Variables):
1816
# APPLE_TEAM_ID — Apple Developer Team ID (e.g. A9P2388PHM)
17+
#
1918

2019
on:
2120
push:
@@ -108,17 +107,26 @@ jobs:
108107
109108
- name: Write App Store Connect API key
110109
env:
111-
API_KEY_B64: ${{ secrets.APP_STORE_CONNECT_PRIVATE_KEY }}
110+
API_KEY: ${{ secrets.APP_STORE_CONNECT_PRIVATE_KEY }}
112111
API_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
113112
run: |
113+
if [[ -z "$API_KEY" ]]; then
114+
echo "::error::APP_STORE_CONNECT_PRIVATE_KEY secret is empty or not set"
115+
exit 1
116+
fi
117+
if [[ -z "$API_KEY_ID" ]]; then
118+
echo "::error::APP_STORE_CONNECT_KEY_ID secret is empty or not set"
119+
exit 1
120+
fi
114121
mkdir -p ~/.appstoreconnect/private_keys
115-
echo "$API_KEY_B64" | base64 --decode \
116-
> ~/.appstoreconnect/private_keys/AuthKey_${API_KEY_ID}.p8
122+
# .p8 is a text/PEM file — write directly, no base64 needed.
123+
printf '%s' "$API_KEY" > ~/.appstoreconnect/private_keys/AuthKey_${API_KEY_ID}.p8
124+
echo "API key written: $(wc -c < ~/.appstoreconnect/private_keys/AuthKey_${API_KEY_ID}.p8) bytes"
117125
118126
- name: Archive (Release)
119127
working-directory: DoomCoderCompanion
120128
env:
121-
APPLE_TEAM_ID: ${{ vars.APPLE_TEAM_ID }}
129+
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
122130
run: |
123131
# Strip the agent's stale GIT_CONFIG vars so SwiftPM can resolve bare repos.
124132
unset GIT_CONFIG_COUNT GIT_CONFIG_KEY_0 GIT_CONFIG_VALUE_0
@@ -144,7 +152,7 @@ jobs:
144152
<dict>
145153
<key>method</key><string>app-store-connect</string>
146154
<key>destination</key><string>upload</string>
147-
<key>teamID</key><string>${{ vars.APPLE_TEAM_ID }}</string>
155+
<key>teamID</key><string>${{ secrets.APPLE_TEAM_ID }}</string>
148156
<key>signingStyle</key><string>automatic</string>
149157
<key>uploadSymbols</key><true/>
150158
<key>uploadBitcode</key><false/>

0 commit comments

Comments
 (0)