forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codemagic.yaml
661 lines (594 loc) · 26.5 KB
/
codemagic.yaml
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
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
workflows:
ios-prod-testflight:
name: Release iOS to Testflight
instance_type: mac_mini_m2
max_build_duration: 120
integrations:
app_store_connect: codemagic_v2
environment:
ios_signing:
provisioning_profiles:
- codemagic_v2
- codemagic_v2_OneSignalNotificationServiceExten
certificates:
- codemagic_v2
groups:
- app_env
- firebase
- shorebird
vars:
APP_ID: 6502156163
flutter: 3.22.3
xcode: 15.4
cocoapods: 1.15.2
cache:
cache_paths:
- $HOME/.pub-cache
- $HOME/.gradle/caches
- $HOME/Library/Caches/CocoaPods
triggering:
events:
- tag
tag_patterns:
- pattern: 'v*-ios-cm'
include: true
- pattern: 'v*-mobile-cm'
include: true
working_directory: app
scripts:
- name: Installing Opus
script: |
brew install opus
brew install opus-tools
- name: Set up Firebase
script: |
dart pub global activate flutterfire_cli
# https://github.com/invertase/flutterfire_cli/issues/233
echo "$FIREBASE_SERVICE_ACCOUNT_KEY" > ./firebase_key.json
flutterfire config \
--platforms="android,ios" \
--out=lib/firebase_options_prod.dart \
--ios-bundle-id=com.friend-app-with-wearable.ios12 \
--android-package-name=com.friend.ios \
--android-out=android/app/src/prod/ \
--ios-out=ios/Config/Prod/ \
--service-account="./firebase_key.json" \
--project="based-hardware" \
--ios-target="Runner" \
--yes \
--macos-bundle-id="no-id" --web-app-id="no-id" --windows-app-id="no-id"
# DEV, should remove
echo "$FIREBASE_SERVICE_ACCOUNT_DEV_KEY" > ./firebase_dev_key.json
flutterfire config \
--platforms="android,ios" \
--out=lib/firebase_options_dev.dart \
--ios-bundle-id=com.friend-app-with-wearable.ios12.development \
--android-app-id=com.friend.ios.dev \
--android-out=android/app/src/dev/ \
--ios-out=ios/Config/Dev/ \
--service-account="./firebase_dev_key.json" \
--project="based-hardware-dev" \
--ios-target="Runner" \
--yes \
--macos-bundle-id="no-id" --web-app-id="no-id" --windows-app-id="no-id"
- name: Set up App .env
script: |
echo OPENAI_API_KEY=$OPENAI_API_KEY >> .env
echo INSTABUG_API_KEY=$INSTABUG_API_KEY >> .env
echo MIXPANEL_PROJECT_TOKEN=$MIXPANEL_PROJECT_TOKEN >> .env
echo ONESIGNAL_APP_ID=$ONESIGNAL_APP_ID >> .env
echo API_BASE_URL=$API_BASE_URL >> .env
echo GROWTHBOOK_API_KEY=$GROWTHBOOK_API_KEY >> .env
echo GOOGLE_MAPS_API_KEY=$GOOGLE_MAPS_API_KEY >> .env
echo INTERCOM_APP_ID=$INTERCOM_APP_ID >> .env
echo INTERCOM_IOS_API_KEY=$INTERCOM_IOS_API_KEY >> .env
- name: Set up Google Service Info
script: |
# TODO: check why we need this ?
echo "$GOOGLE_INFO_PLIST_KEY" > "$(pwd)/ios/Runner/GoogleService-Info.plist"
- name: Get Flutter packages
script: |
flutter pub get
- name: Run build runner
script: |
dart run build_runner build
- name: Instals pod
script: |
cd ios && pod install --repo-update
- name: Flutter build ipa
script: |
# Set up code signing settings on Xcode project
# -> $HOME/export_options.plist
xcode-project use-profiles
# Build
BUILD_NAME=$(echo $CM_TAG | sed 's/^v\(.*\)+\(.*\)-mobile-cm$/\1/')
BUILD_NUMBER=$(echo $CM_TAG | sed 's/^v\(.*\)+\(.*\)-mobile-cm$/\2/')
flutter build ipa \
--release \
--build-name=$BUILD_NAME \
--build-number=$BUILD_NUMBER \
--flavor prod \
--export-options-plist=$HOME/export_options.plist
- name: Generate and zip dSYM files
script: |
# Create a directory for dSYM files
mkdir -p build/ios/dSYMs
# Copy dSYM files to the new directory
cp -R build/ios/archive/Runner.xcarchive/dSYMs/* build/ios/dSYMs/
# Zip dSYM files
cd build/ios/dSYMs
zip -r ios_prod_dsyms.zip *.dSYM
mv ios_prod_dsyms.zip ../../..
cd ../../..
- name: Upload dSYM to Instabug
script: |
curl -X POST "https://api.instabug.com/api/sdk/v3/symbols_files" \
-F os=iOS \
-F symbols_file=@"ios_prod_dsyms.zip" \
-F application_token="$INSTABUG_API_KEY"
artifacts:
- build/ios/ipa/*.ipa
- /tmp/xcodebuild_logs/*.log
- flutter_drive.log
- ios_prod_dsyms.zip
publishing:
email:
recipients:
- ngocthinhdp@gmail.com
- joan@basedhardware.com
- nik@basedhardware.com
- mohsin.lp710@gmail.com
notify:
success: true
failure: false
app_store_connect:
auth: integration
submit_to_testflight: true
beta_groups:
- Internal
- Discord Folks
submit_to_app_store: false
android-prod-internal:
name: Release Android Internal Production
instance_type: mac_mini_m2
max_build_duration: 120
environment:
android_signing:
- prod_android_upload_keystore
groups:
- app_env
- firebase
- google_play
- shorebird
vars:
PACKAGE_NAME: "com.friend.ios"
flutter: 3.22.3
xcode: 15.4
cocoapods: 1.15.2
java: 17
cache:
cache_paths:
- $HOME/opt
- $HOME/.pub-cache
- $HOME/.gradle/caches
triggering:
events:
- tag
tag_patterns:
- pattern: 'v*-android-cm'
include: true
- pattern: 'v*-mobile-cm'
include: true
working_directory: app
scripts:
- name: Installing Android SDK
script: |
export ANDROID_HOME="$HOME/opt/android-sdk"
if [ ! -d "$ANDROID_HOME" ]; then
echo "$ANDROID_HOME does not exist. Installing..."
mkdir -p $ANDROID_HOME
# Install cmdline-tools 11076708; NDK: 27.0.12077973
cd "$HOME/opt" && \
curl --fail --show-error --silent --connect-timeout 10.00 --max-time 120.00 \
--output commandlinetools-mac-11076708_latest.zip \
https://dl.google.com/android/repository/commandlinetools-mac-11076708_latest.zip && \
7z -bd x commandlinetools-mac-11076708_latest.zip && \
mkdir -p $ANDROID_HOME && \
yes | cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "tools" && \
yes | cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "cmdline-tools;latest" && \
yes | cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "ndk;27.0.12077973" && \
yes | cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --licenses && \
cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --list
fi
if [ -d "$ANDROID_HOME" ]; then
echo "$ANDROID_HOME does exist. Setting up env..."
# PATH
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools
# Override ENV
echo ANDROID_HOME="$ANDROID_HOME" >> $CM_ENV
echo ANDROID_SDK_ROOT="$ANDROID_HOME" >> $CM_ENV
echo PATH="$PATH" >> $CM_ENV
fi
- name: Installing Opus
script: |
brew install opus
brew install opus-tools
- name: Set up Firebase
script: |
dart pub global activate flutterfire_cli
# https://github.com/invertase/flutterfire_cli/issues/233
echo "$FIREBASE_SERVICE_ACCOUNT_KEY" > ./firebase_key.json
flutterfire config \
--platforms="android,ios" \
--out=lib/firebase_options_prod.dart \
--ios-bundle-id=com.friend-app-with-wearable.ios12 \
--android-package-name=com.friend.ios \
--android-out=android/app/src/prod/ \
--ios-out=ios/Config/Prod/ \
--service-account="./firebase_key.json" \
--project="based-hardware" \
--ios-target="Runner" \
--yes \
--macos-bundle-id="no-id" --web-app-id="no-id" --windows-app-id="no-id"
# DEV, should remove
echo "$FIREBASE_SERVICE_ACCOUNT_DEV_KEY" > ./firebase_dev_key.json
flutterfire config \
--platforms="android,ios" \
--out=lib/firebase_options_dev.dart \
--ios-bundle-id=com.friend-app-with-wearable.ios12.development \
--android-app-id=com.friend.ios.dev \
--android-out=android/app/src/dev/ \
--ios-out=ios/Config/Dev/ \
--service-account="./firebase_dev_key.json" \
--project="based-hardware-dev" \
--ios-target="Runner" \
--yes \
--macos-bundle-id="no-id" --web-app-id="no-id" --windows-app-id="no-id"
- name: Set up local.properties
script: |
echo "flutter.sdk=$HOME/programs/flutter" > "$(pwd)/android/local.properties"
echo "sdk.dir=$ANDROID_HOME" >> "$(pwd)/android/local.properties"
- name: Set up App .env
script: |
echo OPENAI_API_KEY=$OPENAI_API_KEY >> .env
echo INSTABUG_API_KEY=$INSTABUG_API_KEY >> .env
echo MIXPANEL_PROJECT_TOKEN=$MIXPANEL_PROJECT_TOKEN >> .env
echo ONESIGNAL_APP_ID=$ONESIGNAL_APP_ID >> .env
echo API_BASE_URL=$API_BASE_URL >> .env
echo GROWTHBOOK_API_KEY=$GROWTHBOOK_API_KEY >> .env
echo GOOGLE_MAPS_API_KEY=$GOOGLE_MAPS_API_KEY >> .env
echo INTERCOM_APP_ID=$INTERCOM_APP_ID >> .env
echo INTERCOM_ANDROID_API_KEY=$INTERCOM_ANDROID_API_KEY >> .env
- name: Get Flutter packages
script: |
flutter packages pub get
- name: Run build runner
script: |
dart run build_runner build
- name: Build AAB with Flutter
script: |
# TODO: Don't tricky
# Tricky Opus > build.gradle, force use NDK 27 to deal with "ERROR: Unknown host CPU architecture: arm64"
echo "Z3JvdXAgJ2V1LmVwbncub3B1c19mbHV0dGVyX2FuZHJvaWQnDQp2ZXJzaW9uICcxLjAnDQoNCmJ1aWxkc2NyaXB0IHsNCiAgICByZXBvc2l0b3JpZXMgew0KICAgICAgICBnb29nbGUoKQ0KICAgICAgICBtYXZlbkNlbnRyYWwoKQ0KICAgIH0NCg0KICAgIGRlcGVuZGVuY2llcyB7DQogICAgICAgIGNsYXNzcGF0aCAnY29tLmFuZHJvaWQudG9vbHMuYnVpbGQ6Z3JhZGxlOjcuMy4wJw0KICAgIH0NCn0NCg0Kcm9vdFByb2plY3QuYWxscHJvamVjdHMgew0KICAgIHJlcG9zaXRvcmllcyB7DQogICAgICAgIGdvb2dsZSgpDQogICAgICAgIG1hdmVuQ2VudHJhbCgpDQogICAgfQ0KfQ0KDQphcHBseSBwbHVnaW46ICdjb20uYW5kcm9pZC5saWJyYXJ5Jw0KDQphbmRyb2lkIHsNCiAgICBpZiAocHJvamVjdC5hbmRyb2lkLmhhc1Byb3BlcnR5KCJuYW1lc3BhY2UiKSkgew0KICAgICAgICBuYW1lc3BhY2UgJ2V1LmVwbncub3B1c19mbHV0dGVyX2FuZHJvaWQnDQogICAgfQ0KDQogICAgY29tcGlsZVNka1ZlcnNpb24gMzMNCg0KICAgIGNvbXBpbGVPcHRpb25zIHsNCiAgICAgICAgc291cmNlQ29tcGF0aWJpbGl0eSBKYXZhVmVyc2lvbi5WRVJTSU9OXzFfOA0KICAgICAgICB0YXJnZXRDb21wYXRpYmlsaXR5IEphdmFWZXJzaW9uLlZFUlNJT05fMV84DQogICAgfQ0KDQogICAgZGVmYXVsdENvbmZpZyB7DQogICAgICAgIG1pblNka1ZlcnNpb24gMTkNCiAgICB9DQogICAgZXh0ZXJuYWxOYXRpdmVCdWlsZCB7DQogICAgICAgIG5ka0J1aWxkew0KICAgICAgICAgICAgcGF0aCAiQW5kcm9pZC5tayINCiAgICAgICAgfQ0KICAgIH0NCg0KICAgIGRlcGVuZGVuY2llcyB7DQogICAgICAgIHRlc3RJbXBsZW1lbnRhdGlvbiAnanVuaXQ6anVuaXQ6NC4xMy4yJw0KICAgICAgICB0ZXN0SW1wbGVtZW50YXRpb24gJ29yZy5tb2NraXRvOm1vY2tpdG8tY29yZTo1LjAuMCcNCiAgICB9DQoNCiAgICB0ZXN0T3B0aW9ucyB7DQogICAgICAgIHVuaXRUZXN0cy5hbGwgew0KICAgICAgICAgICAgdGVzdExvZ2dpbmcgew0KICAgICAgICAgICAgICAgZXZlbnRzICJwYXNzZWQiLCAic2tpcHBlZCIsICJmYWlsZWQiLCAic3RhbmRhcmRPdXQiLCAic3RhbmRhcmRFcnJvciINCiAgICAgICAgICAgICAgIG91dHB1dHMudXBUb0RhdGVXaGVuIHtmYWxzZX0NCiAgICAgICAgICAgICAgIHNob3dTdGFuZGFyZFN0cmVhbXMgPSB0cnVlDQogICAgICAgICAgICB9DQogICAgICAgIH0NCiAgICB9DQogICAgbmRrVmVyc2lvbiAnMjcuMC4xMjA3Nzk3MycNCn0NCg==" | base64 -d > "$HOME/.pub-cache/hosted/pub.dev/opus_flutter_android-3.0.1/android/build.gradle"
# Should use bump version automatically by CI
BUILD_NAME=$(echo $CM_TAG | sed 's/^v\(.*\)+\(.*\)-mobile-cm$/\1/')
BUILD_NUMBER=$(echo $CM_TAG | sed 's/^v\(.*\)+\(.*\)-mobile-cm$/\2/')
flutter build appbundle \
--release \
--build-name=$BUILD_NAME \
--build-number=$BUILD_NUMBER \
--flavor prod
- name: Extracting version and Upload mapping file to Instabug
script: |
echo "Instabug mapping files uploader"
GIT_TAG=$(git describe --tags --match="v*-mobile-cm" --abbrev=0)
VERSION_STRING=$(echo $GIT_TAG | sed 's/-mobile-cm$//')
echo "Version String: $VERSION_STRING"
VERSION_NAME="$(echo $VERSION_STRING | cut -d'+' -f1 | sed 's/^v//')"
echo "VERSION_NAME=$VERSION_NAME"
VERSION_CODE="$(echo $VERSION_STRING | cut -d'+' -f2)"
echo "VERSION_CODE=$VERSION_CODE"
APP_TOKEN="$INSTABUG_API_KEY"
PATH_TO_MAPPING_FILE="build/app/outputs/mapping/prodRelease/mapping.txt"
VERSION='{"code":"'"$VERSION_CODE"'","name":"'"$VERSION_NAME"'"}'
if [ ! -f $PATH_TO_MAPPING_FILE ]; then
echo "File not found!"
exit 0
fi
echo "Mapping file found! Uploading..."
ENDPOINT="https://api.instabug.com/api/sdk/v3/symbols_files"
STATUS=$(curl "${ENDPOINT}" --write-out %{http_code} --silent --output /dev/null -F os=android -F app_version="${VERSION}" -F symbols_file=@"${PATH_TO_MAPPING_FILE}" -F application_token="${APP_TOKEN}")
if [ $STATUS -ne 200 ]; then
echo "Error while uploading mapping files"
exit 0
fi
echo "Success! Your mapping files got uploaded successfully"
artifacts:
- build/**/outputs/**/*.aab
- build/**/outputs/**/mapping.txt
- flutter_drive.log
publishing:
email:
recipients:
- ngocthinhdp@gmail.com
- joan@basedhardware.com
- nik@basedhardware.com
- mohsin.lp710@gmail.com
notify:
success: true
failure: false
google_play:
credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS
track: "internal"
submit_as_draft: false
release_promotion:
track: "alpha"
ios-prod-patch:
name: Patch iOS to Production
instance_type: mac_mini_m2
max_build_duration: 120
integrations:
app_store_connect: codemagic_v2
environment:
ios_signing:
provisioning_profiles:
- codemagic_v2
- codemagic_v2_OneSignalNotificationServiceExten
certificates:
- codemagic_v2
groups:
- app_env
- firebase
- shorebird
vars:
APP_ID: 6502156163
flutter: 3.22.3
xcode: 15.4
cocoapods: 1.15.2
cache:
cache_paths:
- $HOME/.pub-cache
- $HOME/.gradle/caches
- $HOME/Library/Caches/CocoaPods
triggering:
events:
- tag
tag_patterns:
- pattern: 'v*-ios-patch-cm'
include: true
- pattern: 'v*-mobile-patch-cm'
include: true
working_directory: app
scripts:
- name: Installing Shorebird
script: |
# Install the Shorebird CLI
curl --proto '=https' --tlsv1.2 https://raw.githubusercontent.com/shorebirdtech/install/main/install.sh -sSf | bash
# Set Shorebird PATH
echo PATH="/Users/builder/.shorebird/bin:$PATH" >> $CM_ENV
- name: Installing Opus
script: |
brew install opus
brew install opus-tools
- name: Set up Firebase
script: |
dart pub global activate flutterfire_cli
# https://github.com/invertase/flutterfire_cli/issues/233
echo "$FIREBASE_SERVICE_ACCOUNT_KEY" > ./firebase_key.json
flutterfire config \
--platforms="android,ios" \
--out=lib/firebase_options_prod.dart \
--ios-bundle-id=com.friend-app-with-wearable.ios12 \
--android-package-name=com.friend.ios \
--android-out=android/app/src/prod/ \
--ios-out=ios/Config/Prod/ \
--service-account="./firebase_key.json" \
--project="based-hardware" \
--ios-target="Runner" \
--yes \
--macos-bundle-id="no-id" --web-app-id="no-id" --windows-app-id="no-id"
# DEV, should remove
echo "$FIREBASE_SERVICE_ACCOUNT_DEV_KEY" > ./firebase_dev_key.json
flutterfire config \
--platforms="android,ios" \
--out=lib/firebase_options_dev.dart \
--ios-bundle-id=com.friend-app-with-wearable.ios12.development \
--android-app-id=com.friend.ios.dev \
--android-out=android/app/src/dev/ \
--ios-out=ios/Config/Dev/ \
--service-account="./firebase_dev_key.json" \
--project="based-hardware-dev" \
--ios-target="Runner" \
--yes \
--macos-bundle-id="no-id" --web-app-id="no-id" --windows-app-id="no-id"
- name: Set up App .env
script: |
echo OPENAI_API_KEY=$OPENAI_API_KEY >> .env
echo INSTABUG_API_KEY=$INSTABUG_API_KEY >> .env
echo MIXPANEL_PROJECT_TOKEN=$MIXPANEL_PROJECT_TOKEN >> .env
echo ONESIGNAL_APP_ID=$ONESIGNAL_APP_ID >> .env
echo API_BASE_URL=$API_BASE_URL >> .env
echo GROWTHBOOK_API_KEY=$GROWTHBOOK_API_KEY >> .env
echo GOOGLE_MAPS_API_KEY=$GOOGLE_MAPS_API_KEY >> .env
echo INTERCOM_APP_ID=$INTERCOM_APP_ID >> .env
echo INTERCOM_IOS_API_KEY=$INTERCOM_IOS_API_KEY >> .env
- name: Set up Google Service Info
script: |
# TODO: check why we need this ?
echo "$GOOGLE_INFO_PLIST_KEY" > "$(pwd)/ios/Runner/GoogleService-Info.plist"
- name: Get Flutter packages
script: |
flutter pub get
- name: Run build runner
script: |
dart run build_runner build
- name: Instals pod
script: |
cd ios && pod install --repo-update
- name: Patch iOS app with Shorebird
script: |
# Set up code signing settings on Xcode project
# -> $HOME/export_options.plist
xcode-project use-profiles
# Build
shorebird patch ios \
--flavor prod -- \
--export-options-plist=$HOME/export_options.plist
artifacts:
- build/ios/ipa/*.ipa
- /tmp/xcodebuild_logs/*.log
- flutter_drive.log
publishing:
email:
recipients:
- ngocthinhdp@gmail.com
- joan@basedhardware.com
- nik@basedhardware.com
- mohsin.lp710@gmail.com
notify:
success: true
failure: false
android-prod-patch:
name: Patch Android to Production
instance_type: mac_mini_m2
max_build_duration: 120
environment:
android_signing:
- prod_android_upload_keystore
groups:
- app_env
- firebase
- shorebird
vars:
PACKAGE_NAME: "com.friend.ios"
flutter: 3.22.3
xcode: 15.4
cocoapods: 1.15.2
java: 17
cache:
cache_paths:
- $HOME/opt
- $HOME/.pub-cache
- $HOME/.gradle/caches
triggering:
events:
- tag
tag_patterns:
- pattern: 'v*-android-patch-cm'
include: true
- pattern: 'v*-mobile-patch-cm'
include: true
working_directory: app
scripts:
- name: Installing Shorebird
script: |
# Install the Shorebird CLI
curl --proto '=https' --tlsv1.2 https://raw.githubusercontent.com/shorebirdtech/install/main/install.sh -sSf | bash
# Set Shorebird PATH
echo PATH="/Users/builder/.shorebird/bin:$PATH" >> $CM_ENV
- name: Installing Android SDK
script: |
export ANDROID_HOME="$HOME/opt/android-sdk"
if [ ! -d "$ANDROID_HOME" ]; then
echo "$ANDROID_HOME does not exist. Installing..."
mkdir -p $ANDROID_HOME
# Install cmdline-tools 11076708; NDK: 27.0.12077973
cd "$HOME/opt" && \
curl --fail --show-error --silent --connect-timeout 10.00 --max-time 120.00 \
--output commandlinetools-mac-11076708_latest.zip \
https://dl.google.com/android/repository/commandlinetools-mac-11076708_latest.zip && \
7z -bd x commandlinetools-mac-11076708_latest.zip && \
mkdir -p $ANDROID_HOME && \
yes | cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "tools" && \
yes | cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "cmdline-tools;latest" && \
yes | cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} "ndk;27.0.12077973" && \
yes | cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --licenses && \
cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_HOME} --list
fi
if [ -d "$ANDROID_HOME" ]; then
echo "$ANDROID_HOME does exist. Setting up env..."
# PATH
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools
# Override ENV
echo ANDROID_HOME="$ANDROID_HOME" >> $CM_ENV
echo ANDROID_SDK_ROOT="$ANDROID_HOME" >> $CM_ENV
echo PATH="$PATH" >> $CM_ENV
fi
- name: Installing Opus
script: |
brew install opus
brew install opus-tools
- name: Set up Firebase
script: |
dart pub global activate flutterfire_cli
# https://github.com/invertase/flutterfire_cli/issues/233
echo "$FIREBASE_SERVICE_ACCOUNT_KEY" > ./firebase_key.json
flutterfire config \
--platforms="android,ios" \
--out=lib/firebase_options_prod.dart \
--ios-bundle-id=com.friend-app-with-wearable.ios12 \
--android-package-name=com.friend.ios \
--android-out=android/app/src/prod/ \
--ios-out=ios/Config/Prod/ \
--service-account="./firebase_key.json" \
--project="based-hardware" \
--ios-target="Runner" \
--yes \
--macos-bundle-id="no-id" --web-app-id="no-id" --windows-app-id="no-id"
# DEV, should remove
echo "$FIREBASE_SERVICE_ACCOUNT_DEV_KEY" > ./firebase_dev_key.json
flutterfire config \
--platforms="android,ios" \
--out=lib/firebase_options_dev.dart \
--ios-bundle-id=com.friend-app-with-wearable.ios12.development \
--android-app-id=com.friend.ios.dev \
--android-out=android/app/src/dev/ \
--ios-out=ios/Config/Dev/ \
--service-account="./firebase_dev_key.json" \
--project="based-hardware-dev" \
--ios-target="Runner" \
--yes \
--macos-bundle-id="no-id" --web-app-id="no-id" --windows-app-id="no-id"
- name: Set up local.properties
script: |
echo "flutter.sdk=$HOME/programs/flutter" > "$(pwd)/android/local.properties"
echo "sdk.dir=$ANDROID_HOME" >> "$(pwd)/android/local.properties"
- name: Set up App .env
script: |
echo OPENAI_API_KEY=$OPENAI_API_KEY >> .env
echo INSTABUG_API_KEY=$INSTABUG_API_KEY >> .env
echo MIXPANEL_PROJECT_TOKEN=$MIXPANEL_PROJECT_TOKEN >> .env
echo ONESIGNAL_APP_ID=$ONESIGNAL_APP_ID >> .env
echo API_BASE_URL=$API_BASE_URL >> .env
echo GROWTHBOOK_API_KEY=$GROWTHBOOK_API_KEY >> .env
echo GOOGLE_MAPS_API_KEY=$GOOGLE_MAPS_API_KEY >> .env
echo INTERCOM_APP_ID=$INTERCOM_APP_ID >> .env
echo INTERCOM_ANDROID_API_KEY=$INTERCOM_ANDROID_API_KEY >> .env
- name: Get Flutter packages
script: |
flutter packages pub get
- name: Run build runner
script: |
dart run build_runner build
- name: Patch Android app with Shorebird
script: |
# TODO: Don't tricky
# Tricky Opus > build.gradle, force use NDK 27 to deal with "ERROR: Unknown host CPU architecture: arm64"
echo "Z3JvdXAgJ2V1LmVwbncub3B1c19mbHV0dGVyX2FuZHJvaWQnDQp2ZXJzaW9uICcxLjAnDQoNCmJ1aWxkc2NyaXB0IHsNCiAgICByZXBvc2l0b3JpZXMgew0KICAgICAgICBnb29nbGUoKQ0KICAgICAgICBtYXZlbkNlbnRyYWwoKQ0KICAgIH0NCg0KICAgIGRlcGVuZGVuY2llcyB7DQogICAgICAgIGNsYXNzcGF0aCAnY29tLmFuZHJvaWQudG9vbHMuYnVpbGQ6Z3JhZGxlOjcuMy4wJw0KICAgIH0NCn0NCg0Kcm9vdFByb2plY3QuYWxscHJvamVjdHMgew0KICAgIHJlcG9zaXRvcmllcyB7DQogICAgICAgIGdvb2dsZSgpDQogICAgICAgIG1hdmVuQ2VudHJhbCgpDQogICAgfQ0KfQ0KDQphcHBseSBwbHVnaW46ICdjb20uYW5kcm9pZC5saWJyYXJ5Jw0KDQphbmRyb2lkIHsNCiAgICBpZiAocHJvamVjdC5hbmRyb2lkLmhhc1Byb3BlcnR5KCJuYW1lc3BhY2UiKSkgew0KICAgICAgICBuYW1lc3BhY2UgJ2V1LmVwbncub3B1c19mbHV0dGVyX2FuZHJvaWQnDQogICAgfQ0KDQogICAgY29tcGlsZVNka1ZlcnNpb24gMzMNCg0KICAgIGNvbXBpbGVPcHRpb25zIHsNCiAgICAgICAgc291cmNlQ29tcGF0aWJpbGl0eSBKYXZhVmVyc2lvbi5WRVJTSU9OXzFfOA0KICAgICAgICB0YXJnZXRDb21wYXRpYmlsaXR5IEphdmFWZXJzaW9uLlZFUlNJT05fMV84DQogICAgfQ0KDQogICAgZGVmYXVsdENvbmZpZyB7DQogICAgICAgIG1pblNka1ZlcnNpb24gMTkNCiAgICB9DQogICAgZXh0ZXJuYWxOYXRpdmVCdWlsZCB7DQogICAgICAgIG5ka0J1aWxkew0KICAgICAgICAgICAgcGF0aCAiQW5kcm9pZC5tayINCiAgICAgICAgfQ0KICAgIH0NCg0KICAgIGRlcGVuZGVuY2llcyB7DQogICAgICAgIHRlc3RJbXBsZW1lbnRhdGlvbiAnanVuaXQ6anVuaXQ6NC4xMy4yJw0KICAgICAgICB0ZXN0SW1wbGVtZW50YXRpb24gJ29yZy5tb2NraXRvOm1vY2tpdG8tY29yZTo1LjAuMCcNCiAgICB9DQoNCiAgICB0ZXN0T3B0aW9ucyB7DQogICAgICAgIHVuaXRUZXN0cy5hbGwgew0KICAgICAgICAgICAgdGVzdExvZ2dpbmcgew0KICAgICAgICAgICAgICAgZXZlbnRzICJwYXNzZWQiLCAic2tpcHBlZCIsICJmYWlsZWQiLCAic3RhbmRhcmRPdXQiLCAic3RhbmRhcmRFcnJvciINCiAgICAgICAgICAgICAgIG91dHB1dHMudXBUb0RhdGVXaGVuIHtmYWxzZX0NCiAgICAgICAgICAgICAgIHNob3dTdGFuZGFyZFN0cmVhbXMgPSB0cnVlDQogICAgICAgICAgICB9DQogICAgICAgIH0NCiAgICB9DQogICAgbmRrVmVyc2lvbiAnMjcuMC4xMjA3Nzk3MycNCn0NCg==" | base64 -d > "$HOME/.pub-cache/hosted/pub.dev/opus_flutter_android-3.0.1/android/build.gradle"
# Should use bump version automatically by CI
shorebird patch android \
--flavor prod
artifacts:
- build/**/outputs/**/*.aab
- build/**/outputs/**/mapping.txt
- flutter_drive.log
publishing:
email:
recipients:
- ngocthinhdp@gmail.com
- joan@basedhardware.com
- nik@basedhardware.com
- mohsin.lp710@gmail.com
notify:
success: true
failure: false