-
Notifications
You must be signed in to change notification settings - Fork 0
247 lines (227 loc) · 8.3 KB
/
Copy pathnative-macos-testflight.yml
File metadata and controls
247 lines (227 loc) · 8.3 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
---
name: Native macOS TestFlight
'on':
push:
tags:
- 'macos-v*'
workflow_dispatch:
inputs:
git_ref:
description: "Git ref to build (branch, tag, or SHA)"
required: false
default: ""
upload_to_testflight:
description: "Upload exported package to TestFlight"
required: true
type: boolean
default: true
permissions:
contents: read
concurrency:
group: native-macos-testflight-${{ github.ref }}
cancel-in-progress: false
jobs:
build-and-upload:
name: Build signed macOS package
runs-on: macos-15
env:
APPLE_TEAM_ID: MM5YXC7T6E
BUNDLE_ID: com.shinycomputers.everycodecompanion.macos
SCHEME: CodeNativeMac
XCODE_PROJECT: native/CodeNativeMac/CodeNativeMac.xcodeproj
ARCHIVE_PATH: /tmp/ecc-macos/EveryCodeCompanion.xcarchive
EXPORT_PATH: /tmp/ecc-macos/export
EXPORT_OPTIONS_PATH: /tmp/ecc-macos/ExportOptions.plist
PROFILE_PATH: /tmp/ecc-macos/every-code-companion-macos.provisionprofile
steps:
- name: Resolve checkout ref
id: resolve_ref
run: |
set -euo pipefail
ref="$GITHUB_REF"
if [ "${{ github.event_name }}" = "workflow_dispatch" ] \
&& [ -n "${{ github.event.inputs.git_ref }}" ]; then
ref="${{ github.event.inputs.git_ref }}"
fi
echo "value=$ref" >> "$GITHUB_OUTPUT"
- name: Prepare build directories
run: |
set -euo pipefail
mkdir -p "$(dirname "$ARCHIVE_PATH")"
mkdir -p "$EXPORT_PATH"
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ steps.resolve_ref.outputs.value }}
- name: Generate macOS project
run: |
set -euo pipefail
cd native/CodeNativeMac
xcodegen generate
- name: Select Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Validate required secrets
env:
IOS_DIST_CERT_P12_BASE64: ${{ secrets.IOS_DIST_CERT_P12_BASE64 }}
IOS_DIST_CERT_PASSWORD: ${{ secrets.IOS_DIST_CERT_PASSWORD }}
MACOS_APPSTORE_PROFILE_BASE64:
${{ secrets.MACOS_APPSTORE_PROFILE_BASE64 }}
MACOS_APPSTORE_PROFILE_NAME:
${{ secrets.MACOS_APPSTORE_PROFILE_NAME }}
APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
APP_STORE_CONNECT_ISSUER_ID:
${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
APP_STORE_CONNECT_PRIVATE_KEY:
${{ secrets.APP_STORE_CONNECT_PRIVATE_KEY }}
run: |
set -euo pipefail
missing=()
for name in \
IOS_DIST_CERT_P12_BASE64 \
IOS_DIST_CERT_PASSWORD \
MACOS_APPSTORE_PROFILE_BASE64 \
MACOS_APPSTORE_PROFILE_NAME \
APP_STORE_CONNECT_KEY_ID \
APP_STORE_CONNECT_ISSUER_ID \
APP_STORE_CONNECT_PRIVATE_KEY; do
if [ -z "${!name:-}" ]; then
missing+=("$name")
fi
done
if [ "${#missing[@]}" -gt 0 ]; then
printf 'Missing required secrets:\n' >&2
printf ' - %s\n' "${missing[@]}" >&2
exit 1
fi
- name: Import Apple Distribution certificate
uses: apple-actions/import-codesign-certs@v3
with:
p12-file-base64: ${{ secrets.IOS_DIST_CERT_P12_BASE64 }}
p12-password: ${{ secrets.IOS_DIST_CERT_PASSWORD }}
- name: Install Mac App Store provisioning profile
env:
MACOS_APPSTORE_PROFILE_BASE64:
${{ secrets.MACOS_APPSTORE_PROFILE_BASE64 }}
run: |
set -euo pipefail
mkdir -p "$HOME/Library/MobileDevice/Provisioning Profiles"
echo "$MACOS_APPSTORE_PROFILE_BASE64" | base64 --decode \
> "$PROFILE_PATH"
profile_plist=$(security cms -D -i "$PROFILE_PATH")
profile_uuid=$(
/usr/libexec/PlistBuddy -c 'Print UUID' /dev/stdin \
<<<"$profile_plist"
)
profiles_dir="$HOME/Library/MobileDevice/Provisioning Profiles"
cp "$PROFILE_PATH" "$profiles_dir/$profile_uuid.provisionprofile"
- name: Write export options
env:
MACOS_APPSTORE_PROFILE_NAME:
${{ secrets.MACOS_APPSTORE_PROFILE_NAME }}
run: |
set -euo pipefail
cat > "$EXPORT_OPTIONS_PATH" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>destination</key>
<string>export</string>
<key>method</key>
<string>app-store-connect</string>
<key>signingStyle</key>
<string>manual</string>
<key>stripSwiftSymbols</key>
<true/>
<key>teamID</key>
<string>${APPLE_TEAM_ID}</string>
<key>provisioningProfiles</key>
<dict>
<key>${BUNDLE_ID}</key>
<string>${MACOS_APPSTORE_PROFILE_NAME}</string>
</dict>
</dict>
</plist>
EOF
- name: Archive macOS app
env:
MACOS_APPSTORE_PROFILE_NAME:
${{ secrets.MACOS_APPSTORE_PROFILE_NAME }}
run: |
set -euo pipefail
xcodebuild \
-project "$XCODE_PROJECT" \
-scheme "$SCHEME" \
-configuration Release \
-destination "generic/platform=macOS" \
-archivePath "$ARCHIVE_PATH" \
DEVELOPMENT_TEAM="$APPLE_TEAM_ID" \
PRODUCT_BUNDLE_IDENTIFIER="$BUNDLE_ID" \
CODE_SIGN_STYLE=Manual \
CODE_SIGN_IDENTITY="Apple Distribution" \
PROVISIONING_PROFILE_SPECIFIER="$MACOS_APPSTORE_PROFILE_NAME" \
clean archive
- name: Export package
run: |
set -euo pipefail
xcodebuild \
-exportArchive \
-archivePath "$ARCHIVE_PATH" \
-exportPath "$EXPORT_PATH" \
-exportOptionsPlist "$EXPORT_OPTIONS_PATH"
pkg_path=$(find "$EXPORT_PATH" -maxdepth 1 -name '*.pkg' -print -quit)
if [ -z "$pkg_path" ]; then
echo "No PKG produced by export" >&2
exit 1
fi
mv "$pkg_path" "$EXPORT_PATH/EveryCodeCompanion.pkg"
- name: Install App Store Connect API key
env:
APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
APP_STORE_CONNECT_PRIVATE_KEY:
${{ secrets.APP_STORE_CONNECT_PRIVATE_KEY }}
run: |
set -euo pipefail
key_dir="$HOME/.appstoreconnect/private_keys"
key_path="$key_dir/AuthKey_${APP_STORE_CONNECT_KEY_ID}.p8"
mkdir -p "$key_dir"
printf '%s' "$APP_STORE_CONNECT_PRIVATE_KEY" > "$key_path"
chmod 600 "$key_path"
- name: Upload package artifact
uses: actions/upload-artifact@v4
with:
name: EveryCodeCompanion-macos-pkg
path: |
${{ env.EXPORT_PATH }}/EveryCodeCompanion.pkg
${{ env.ARCHIVE_PATH }}/dSYMs
if-no-files-found: error
- name: Upload to TestFlight
if: >-
${{ github.event_name == 'push'
|| github.event.inputs.upload_to_testflight == 'true' }}
env:
APP_STORE_CONNECT_KEY_ID: ${{ secrets.APP_STORE_CONNECT_KEY_ID }}
APP_STORE_CONNECT_ISSUER_ID:
${{ secrets.APP_STORE_CONNECT_ISSUER_ID }}
run: |
set -euo pipefail
log_path=/tmp/ecc-macos-upload.log
xcrun altool --output-format xml \
--upload-app \
--file "$EXPORT_PATH/EveryCodeCompanion.pkg" \
--type macos \
--apiKey "$APP_STORE_CONNECT_KEY_ID" \
--apiIssuer "$APP_STORE_CONNECT_ISSUER_ID" \
| tee "$log_path"
if rg -q "UPLOAD FAILED|Validation failed| ERROR:" "$log_path"; then
echo "Detected upload failure markers in altool output" >&2
exit 1
fi
if ! rg -q "UPLOAD SUCCEEDED with no errors" "$log_path"; then
echo "Upload result did not include success marker" >&2
exit 1
fi