-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathcodemagic.yaml
More file actions
563 lines (550 loc) · 19.2 KB
/
codemagic.yaml
File metadata and controls
563 lines (550 loc) · 19.2 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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
# ABOUTME: Codemagic CI/CD configuration for Divine mobile app builds.
# ABOUTME: Configured for iOS and Android builds with manual triggering only.
# Steps to setup:
# 1 - Create the Codemagic project with access to the repository.
# 2 - Setup iOS publishing:
# 2.1 - https://docs.codemagic.io/yaml-quick-start/building-a-flutter-app/#:~:text=Creating%20the%20App%20Store%20Connect%20API%20key
# 3 - Setup Android publishing:
# 3.1 - Code signing: https://docs.codemagic.io/yaml-quick-start/building-a-flutter-app/#:~:text=Generating%20a%20keystore
# 3.2 - Connect to Google Play: https://docs.codemagic.io/yaml-publishing/google-play/
# 4 - Setup emails to receive build notifications.
# 5 - Create environment variable group "zendesk_credentials" with:
# - ZENDESK_APP_ID
# - ZENDESK_CLIENT_ID
# - ZENDESK_URL
# 6 - DEFAULT_ENV is configured via build inputs (dropdown) when starting a build
# - Options: PRODUCTION, STAGING, TEST, POC
# - Defaults to PRODUCTION for automatic builds
# 7 - Create environment variable group "proofmode_credentials" with:
# - PROOFMODE_SIGNING_SERVER_ENDPOINT
# - PROOFMODE_SIGNING_SERVER_TOKEN
# 8 - PUBLISH_TO_GITHUB is configured via build inputs (dropdown) when starting builds
# - Set to YES to upload artifacts to a GitHub Release (for Zapstore / direct distribution)
# - Defaults to NO
# - Requires GITHUB_TOKEN in "github_credentials" environment variable group
definitions:
environment:
emails: &emails
- TODO
scripts:
- &setup_code_signing_xcode
name: Set up code signing settings on Xcode project
script: xcode-project use-profiles
- &install_flutterfire
name: Install FlutterFire CLI
script: dart pub global activate flutterfire_cli
- &enable_spm
name: Enable Swift Package Manager
script: flutter config --enable-swift-package-manager
- &flutter_pub_get
name: Get Flutter dependencies
script: flutter pub get
- &pod_install
name: Run pod install
script: find . -name "Podfile" -execdir pod install \;
- &setup_local_properties
name: Set up local.properties
script: echo "flutter.sdk=$FLUTTER_ROOT" > "$CM_BUILD_DIR/mobile/android/local.properties"
- &build_apk
name: Build Android APK
script: |
flutter build apk --release --split-per-abi --build-number=$PROJECT_BUILD_NUMBER \
--dart-define=ZENDESK_APP_ID=$ZENDESK_APP_ID \
--dart-define=ZENDESK_CLIENT_ID=$ZENDESK_CLIENT_ID \
--dart-define=ZENDESK_URL=$ZENDESK_URL \
--dart-define=DEFAULT_ENV=${{ inputs.DEFAULT_ENV }} \
--dart-define=PROOFMODE_SIGNING_SERVER_ENDPOINT=$PROOFMODE_SIGNING_SERVER_ENDPOINT \
--dart-define=PROOFMODE_SIGNING_SERVER_TOKEN=$PROOFMODE_SIGNING_SERVER_TOKEN
- &build_aab
name: Build Android AAB
script: |
# Offset to continue from existing Google Play builds (GP has up to 108, CM at 100)
BUILD_NUMBER=$((PROJECT_BUILD_NUMBER + 8))
flutter build appbundle --release --build-number=$BUILD_NUMBER \
--dart-define=ZENDESK_APP_ID=$ZENDESK_APP_ID \
--dart-define=ZENDESK_CLIENT_ID=$ZENDESK_CLIENT_ID \
--dart-define=ZENDESK_URL=$ZENDESK_URL \
--dart-define=DEFAULT_ENV=${{ inputs.DEFAULT_ENV }} \
--dart-define=PROOFMODE_SIGNING_SERVER_ENDPOINT=$PROOFMODE_SIGNING_SERVER_ENDPOINT \
--dart-define=PROOFMODE_SIGNING_SERVER_TOKEN=$PROOFMODE_SIGNING_SERVER_TOKEN
- &build_macos
name: Build macOS app
script: |
# This workflow packages a DMG for direct download. It does not provision
# a macOS signing identity/profile in Codemagic, so disable signing for
# the CI build and handle signing/notarization separately when needed.
env CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO flutter build macos --release \
--dart-define=ZENDESK_APP_ID=$ZENDESK_APP_ID \
--dart-define=ZENDESK_CLIENT_ID=$ZENDESK_CLIENT_ID \
--dart-define=ZENDESK_URL=$ZENDESK_URL \
--dart-define=DEFAULT_ENV=${{ inputs.DEFAULT_ENV }} \
--dart-define=PROOFMODE_SIGNING_SERVER_ENDPOINT=$PROOFMODE_SIGNING_SERVER_ENDPOINT \
--dart-define=PROOFMODE_SIGNING_SERVER_TOKEN=$PROOFMODE_SIGNING_SERVER_TOKEN
- &package_macos_dmg
name: Package macOS DMG
script: |
APP_PATH="build/macos/Build/Products/Release"
APP_NAME=$(ls "$APP_PATH" | grep '\.app$' | head -1)
DMG_NAME="Divine-macOS.dmg"
echo "Packaging $APP_NAME as $DMG_NAME"
hdiutil create -volname "Divine" -srcfolder "$APP_PATH/$APP_NAME" \
-ov -format UDZO "$APP_PATH/$DMG_NAME"
- &publish_github_release
name: Publish to GitHub Release
script: |
if [ "${{ inputs.PUBLISH_TO_GITHUB }}" != "YES" ]; then
echo "Skipping GitHub Release (PUBLISH_TO_GITHUB != YES)"
exit 0
fi
VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //' | sed 's/+.*//')
TAG="$VERSION"
echo "Publishing to GitHub Release $TAG"
# Collect artifacts that exist for this platform
ARTIFACTS=()
# Android APKs
for f in build/app/outputs/apk/release/*arm64*.apk build/app/outputs/apk/release/*armeabi*.apk; do
[ -f "$f" ] && ARTIFACTS+=("$f")
done
# iOS IPA
for f in build/ios/ipa/*.ipa; do
[ -f "$f" ] && ARTIFACTS+=("$f")
done
# macOS DMG
for f in build/macos/Build/Products/Release/*.dmg; do
[ -f "$f" ] && ARTIFACTS+=("$f")
done
if [ ${#ARTIFACTS[@]} -eq 0 ]; then
echo "No artifacts found to upload"
exit 1
fi
echo "Uploading ${#ARTIFACTS[@]} artifact(s): ${ARTIFACTS[*]}"
# If release already exists, upload assets to it; otherwise create new
if gh release view "$TAG" --repo "$CM_REPO_SLUG" > /dev/null 2>&1; then
echo "Release $TAG exists, uploading assets (replacing existing)"
gh release upload "$TAG" \
--repo "$CM_REPO_SLUG" \
--clobber \
"${ARTIFACTS[@]}"
else
echo "Creating new release $TAG"
gh release create "$TAG" \
--repo "$CM_REPO_SLUG" \
--title "$TAG" \
--prerelease \
--generate-notes \
"${ARTIFACTS[@]}"
fi
- &build_ios
name: Build and sign iOS
script: |
# Offset to continue from existing manual builds
BUILD_NUMBER=$((PROJECT_BUILD_NUMBER + 142))
flutter build ipa --release --build-number=$BUILD_NUMBER \
--dart-define=ZENDESK_APP_ID=$ZENDESK_APP_ID \
--dart-define=ZENDESK_CLIENT_ID=$ZENDESK_CLIENT_ID \
--dart-define=ZENDESK_URL=$ZENDESK_URL \
--dart-define=DEFAULT_ENV=${{ inputs.DEFAULT_ENV }} \
--dart-define=PROOFMODE_SIGNING_SERVER_ENDPOINT=$PROOFMODE_SIGNING_SERVER_ENDPOINT \
--dart-define=PROOFMODE_SIGNING_SERVER_TOKEN=$PROOFMODE_SIGNING_SERVER_TOKEN \
--export-options-plist=/Users/builder/export_options.plist
- &upload_dsyms_to_crashlytics
name: Upload dSYMs to Firebase Crashlytics
script: |
DSYM_DIR="build/ios/archive/Runner.xcarchive/dSYMs"
if [ ! -d "$DSYM_DIR" ]; then
echo "ERROR: dSYM directory not found at $DSYM_DIR"
find build/ios -name "*.dSYM" -type d 2>/dev/null || true
exit 1
fi
echo "Found dSYMs:"
ls -la "$DSYM_DIR"
# Find the Crashlytics upload-symbols tool from the SPM build
UPLOAD_SYMBOLS=$(find "$HOME/Library/Developer/Xcode/DerivedData" -name "upload-symbols" -type f 2>/dev/null | head -1)
if [ -z "$UPLOAD_SYMBOLS" ]; then
UPLOAD_SYMBOLS=$(find . -path "*/FirebaseCrashlytics*" -name "upload-symbols" -type f 2>/dev/null | head -1)
fi
if [ -z "$UPLOAD_SYMBOLS" ]; then
echo "ERROR: upload-symbols tool not found. Searching all locations..."
find "$HOME" -name "upload-symbols" -type f 2>/dev/null || true
find . -name "upload-symbols" -type f 2>/dev/null || true
exit 1
fi
echo "Found upload-symbols at: $UPLOAD_SYMBOLS"
chmod +x "$UPLOAD_SYMBOLS"
"$UPLOAD_SYMBOLS" \
-gsp ios/Runner/GoogleService-Info.plist \
-p ios \
"$DSYM_DIR"
- &build_ios_simulator
name: Build iOS Simulator app
script: |
flutter build ios --simulator \
--dart-define=ZENDESK_APP_ID=$ZENDESK_APP_ID \
--dart-define=ZENDESK_CLIENT_ID=$ZENDESK_CLIENT_ID \
--dart-define=ZENDESK_URL=$ZENDESK_URL \
--dart-define=DEFAULT_ENV=${{ inputs.DEFAULT_ENV }} \
--dart-define=PROOFMODE_SIGNING_SERVER_ENDPOINT=$PROOFMODE_SIGNING_SERVER_ENDPOINT \
--dart-define=PROOFMODE_SIGNING_SERVER_TOKEN=$PROOFMODE_SIGNING_SERVER_TOKEN
- &build_ios_e2e
name: Build iOS Simulator app
script: |
flutter build ios --simulator \
--dart-define=ZENDESK_APP_ID=$ZENDESK_APP_ID \
--dart-define=ZENDESK_CLIENT_ID=$ZENDESK_CLIENT_ID \
--dart-define=ZENDESK_URL=$ZENDESK_URL \
--dart-define=DEFAULT_ENV=$DEFAULT_ENV \
--dart-define=PROOFMODE_SIGNING_SERVER_ENDPOINT=$PROOFMODE_SIGNING_SERVER_ENDPOINT \
--dart-define=PROOFMODE_SIGNING_SERVER_TOKEN=$PROOFMODE_SIGNING_SERVER_TOKEN
- &build_android_e2e
name: Build Android debug APK
script: |
flutter build apk --debug \
--dart-define=ZENDESK_APP_ID=$ZENDESK_APP_ID \
--dart-define=ZENDESK_CLIENT_ID=$ZENDESK_CLIENT_ID \
--dart-define=ZENDESK_URL=$ZENDESK_URL \
--dart-define=DEFAULT_ENV=$DEFAULT_ENV \
--dart-define=PROOFMODE_SIGNING_SERVER_ENDPOINT=$PROOFMODE_SIGNING_SERVER_ENDPOINT \
--dart-define=PROOFMODE_SIGNING_SERVER_TOKEN=$PROOFMODE_SIGNING_SERVER_TOKEN
- &install_maestro
name: Install Maestro CLI
script: |
set -e
curl -Ls "https://get.maestro.mobile.dev" | bash
export PATH="$PATH:$HOME/.maestro/bin"
maestro --version
- &run_maestro_smoke_tests
name: Run Maestro Smoke Tests
script: |
set -e
export PATH="$PATH:$HOME/.maestro/bin"
maestro test e2e/maestro/suites/smoke.yaml
- &boot_ios_simulator
name: Boot iOS Simulator
script: |
DEVICE_UDID=$(xcrun simctl list devices available -j | \
python3 -c "
import json, sys
data = json.load(sys.stdin)
for runtime, devices in data['devices'].items():
for d in devices:
if d['name'] == 'iPhone 16 Pro' and d['isAvailable']:
print(d['udid'])
sys.exit(0)
sys.exit(1)
")
xcrun simctl boot "$DEVICE_UDID" || true
echo "Booted simulator: $DEVICE_UDID"
- &install_app_ios_simulator
name: Install app on iOS Simulator
script: |
APP_PATH="build/ios/iphonesimulator/Runner.app"
DEVICE_UDID=$(xcrun simctl list devices booted -j | \
python3 -c "
import json, sys
data = json.load(sys.stdin)
for runtime, devices in data['devices'].items():
for d in devices:
if d['state'] == 'Booted':
print(d['udid'])
sys.exit(0)
sys.exit(1)
")
xcrun simctl uninstall "$DEVICE_UDID" "$BUNDLE_ID" 2>/dev/null || true
xcrun simctl install "$DEVICE_UDID" "$APP_PATH"
echo "App installed on iOS simulator: $DEVICE_UDID"
- &launch_android_emulator
name: Launch Android emulator
script: |
set -e
cd $ANDROID_HOME/tools
emulator -avd emulator &
adb wait-for-device
TIMEOUT=120
ELAPSED=0
while [ "$(adb shell getprop sys.boot_completed 2>/dev/null)" != "1" ]; do
if [ "$ELAPSED" -ge "$TIMEOUT" ]; then
echo "ERROR: Android emulator failed to boot within ${TIMEOUT}s"
exit 1
fi
echo "Waiting for Android emulator to boot... (${ELAPSED}s/${TIMEOUT}s)"
sleep 5
ELAPSED=$((ELAPSED + 5))
done
echo "Android emulator booted"
- &install_app_android_emulator
name: Install app on Android emulator
script: |
set -e
APK_PATH="build/app/outputs/flutter-apk/app-debug.apk"
if [ ! -f "$APK_PATH" ]; then
echo "ERROR: APK not found at $APK_PATH"
exit 1
fi
adb install "$APK_PATH"
echo "App installed on Android emulator"
workflows:
ios-build:
name: iOS Build
working_directory: mobile
max_build_duration: 60
instance_type: mac_mini_m2
integrations:
app_store_connect: API key for Codemagic # Setup in Codemagic UI
inputs:
DEFAULT_ENV:
description: Default environment for fresh app installs
type: choice
default: PRODUCTION
options:
- PRODUCTION
- STAGING
- TEST
- POC
PUBLISH_TO_GITHUB:
description: Upload IPA to GitHub Release (for direct distribution)
type: choice
default: "NO"
options:
- "NO"
- "YES"
environment:
flutter: 3.41.1
xcode: latest
cocoapods: default
groups:
- zendesk_credentials
- proofmode_credentials
- github_credentials
vars:
BUNDLE_ID: co.openvine.app
ios_signing:
distribution_type: app_store
bundle_identifier: $BUNDLE_ID
cache:
cache_paths:
- $HOME/Library/Caches/CocoaPods
- $HOME/.pub-cache
triggering:
events: []
scripts:
- *setup_code_signing_xcode
- *install_flutterfire
- *enable_spm
- *pod_install
- *build_ios
- *upload_dsyms_to_crashlytics
- *publish_github_release
artifacts:
- build/ios/ipa/*.ipa
- build/ios/archive/Runner.xcarchive/dSYMs/**
- /tmp/xcodebuild_logs/*.log
- flutter_drive.log
publishing:
app_store_connect:
auth: integration
submit_to_testflight: true
submit_to_app_store: false
# Don't auto-distribute to any groups - we'll manually add builds to external testers
beta_groups: []
ios-simulator-build:
name: iOS Simulator Build
working_directory: mobile
max_build_duration: 60
instance_type: mac_mini_m2
inputs:
DEFAULT_ENV:
description: Default environment for fresh app installs
type: choice
default: PRODUCTION
options:
- PRODUCTION
- STAGING
- TEST
- POC
environment:
flutter: 3.41.1
xcode: 16.1 # Pinned to avoid FFmpeg Kit linker issues with newer Xcode
cocoapods: default
groups:
- zendesk_credentials
- proofmode_credentials
cache:
cache_paths:
- $HOME/Library/Caches/CocoaPods
- $HOME/.pub-cache
triggering:
events: []
scripts:
- *install_flutterfire
- *enable_spm
- *flutter_pub_get
- *pod_install
- *build_ios_simulator
artifacts:
- build/ios/iphonesimulator/Runner.app
- /tmp/xcodebuild_logs/*.log
android-build:
name: Android Build
working_directory: mobile
max_build_duration: 60
instance_type: mac_mini_m2
inputs:
DEFAULT_ENV:
description: Default environment for fresh app installs
type: choice
default: PRODUCTION
options:
- PRODUCTION
- STAGING
- TEST
- POC
PUBLISH_TO_GITHUB:
description: Create a GitHub Release with APK artifacts (for Zapstore)
type: choice
default: "NO"
options:
- "NO"
- "YES"
environment:
flutter: 3.41.1
java: 17
groups:
- zendesk_credentials
- google_play_credentials
- proofmode_credentials
- github_credentials
android_signing:
- divine_keystore
cache:
cache_paths:
- $HOME/.gradle/caches
- $HOME/.pub-cache
triggering:
events: []
scripts:
- *enable_spm
- *setup_local_properties
- *build_apk
- *build_aab
- *publish_github_release
artifacts:
- build/app/outputs/apk/release/*.apk
- build/app/outputs/bundle/release/*.aab
- build/app/outputs/mapping/**/mapping.txt
publishing:
google_play:
credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS
track: internal
macos-build:
name: macOS Build
working_directory: mobile
max_build_duration: 60
instance_type: mac_mini_m2
inputs:
DEFAULT_ENV:
description: Default environment for fresh app installs
type: choice
default: PRODUCTION
options:
- PRODUCTION
- STAGING
- TEST
- POC
PUBLISH_TO_GITHUB:
description: Upload DMG to GitHub Release (for direct distribution)
type: choice
default: "NO"
options:
- "NO"
- "YES"
environment:
flutter: 3.41.1
xcode: latest
cocoapods: default
groups:
- zendesk_credentials
- proofmode_credentials
- github_credentials
cache:
cache_paths:
- $HOME/Library/Caches/CocoaPods
- $HOME/.pub-cache
triggering:
events: []
scripts:
- *install_flutterfire
- *enable_spm
- *flutter_pub_get
- *pod_install
- *build_macos
- *package_macos_dmg
- *publish_github_release
artifacts:
- build/macos/Build/Products/Release/*.dmg
- build/macos/Build/Products/Release/*.app
e2e-smoke-ios:
name: E2E Smoke Tests (iOS)
working_directory: mobile
max_build_duration: 60
instance_type: mac_mini_m2
environment:
flutter: 3.41.1
xcode: 16.1
cocoapods: default
groups:
- zendesk_credentials
- proofmode_credentials
vars:
DEFAULT_ENV: STAGING
BUNDLE_ID: co.openvine.app
cache:
cache_paths:
- $HOME/Library/Caches/CocoaPods
- $HOME/.pub-cache
triggering:
events: []
scripts:
- *install_flutterfire
- *enable_spm
- *flutter_pub_get
- *pod_install
- *build_ios_e2e
- *install_maestro
- *boot_ios_simulator
- *install_app_ios_simulator
- *run_maestro_smoke_tests
artifacts:
- build/ios/iphonesimulator/Runner.app
- /tmp/xcodebuild_logs/*.log
- ~/.maestro/tests/**
e2e-smoke-android:
name: E2E Smoke Tests (Android)
working_directory: mobile
max_build_duration: 60
instance_type: linux_x2
environment:
flutter: 3.41.1
java: 17
groups:
- zendesk_credentials
- proofmode_credentials
vars:
DEFAULT_ENV: STAGING
BUNDLE_ID: co.openvine.app
cache:
cache_paths:
- $HOME/.gradle/caches
- $HOME/.pub-cache
triggering:
events: []
scripts:
- *flutter_pub_get
- *setup_local_properties
- *build_android_e2e
- *install_maestro
- *launch_android_emulator
- *install_app_android_emulator
- *run_maestro_smoke_tests
artifacts:
- build/app/outputs/flutter-apk/app-debug.apk
- ~/.maestro/tests/**