-
Notifications
You must be signed in to change notification settings - Fork 17
1426 lines (1252 loc) · 52.2 KB
/
ci.yml
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
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: CI
on:
push:
branches: ["main"]
tags: ["helm/**", "v*"]
pull_request:
branches: ["main"]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FLUTTER_VER: "3.27"
jobs:
################
# Pull Request #
################
pr:
if: ${{ github.event_name == 'pull_request' }}
needs:
- appcast
- build
- build-linux
- copyright
- dartanalyze
- dartdoc
- dartfmt
- docker
- helm-lint
- pubspec
- test-e2e
- test-unit
- validate-publish
runs-on: ubuntu-latest
steps:
- run: true
##########################
# Linting and formatting #
##########################
copyright:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: make copyright check=yes
dartanalyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # for correct versioning via `git describe --tags`
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VER }}
channel: stable
cache: true
- run: make flutter.pub
- run: make flutter.analyze
dartfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VER }}
channel: stable
cache: true
- run: make flutter.fmt check=yes
helm-lint:
name: helm lint
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
strategy:
fail-fast: false
matrix:
chart: ["messenger"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: azure/setup-helm@v4
- run: make helm.lint chart=${{ matrix.chart }}
pubspec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VER }}
channel: stable
cache: true
- run: make flutter.pub
- name: Check `pubspec.lock` is in sync with `pubspec.yaml`
run: git diff --exit-code
validate-publish:
name: validate (${{ matrix.store }})
if: ${{ github.event_name == 'pull_request' }}
needs: ["build"]
strategy:
matrix:
store:
- App Store
- Google Play
runs-on: ${{ matrix.store == 'App Store' && 'macos'
|| 'ubuntu' }}-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # For commit message retrieving.
- name: Retrieve last commit messages
id: commit
run: |
echo "message=$(git log --grep='\[run ci\]' --format=%s)" \
>> $GITHUB_OUTPUT
- name: Determine whether `fastlane/` directory has any changes
uses: dorny/paths-filter@v3
id: changed
with:
filters: |
fastlane:
- '${{ (matrix.store == 'App Store' && 'ios')
|| (matrix.store == 'Google Play' && 'android')
}}/fastlane/**'
# Skip if there are no changes in `fastlane/` directory and no `[run ci]`
# mark is detected in the last commit message.
- id: skip
run: echo "no=${{ steps.changed.outputs.fastlane == 'true'
|| contains(steps.commit.outputs.message, '[run ci]') }}"
>> $GITHUB_OUTPUT
- uses: actions/download-artifact@v4
with:
name: build-${{ (matrix.store == 'App Store' && 'ipa')
|| (matrix.store == 'Google Play' && 'appbundle')
}}-${{ github.run_number }}
if: ${{ steps.skip.outputs.no == 'true' }}
- run: mv *.ipa ios/app.ipa
if: ${{ steps.skip.outputs.no == 'true'
&& matrix.store == 'App Store' }}
- run: mv *.aab android/app.aab
if: ${{ steps.skip.outputs.no == 'true'
&& matrix.store == 'Google Play' }}
- name: Prepare App Store Connect key
run: echo "${{ secrets.APP_STORE_KEY }}"
>> ${{ runner.temp }}/AuthKey_${{ secrets.APP_STORE_IDENTIFIER }}.p8
if: ${{ steps.skip.outputs.no == 'true'
&& matrix.store == 'App Store' }}
- name: Prepare Google Service account
run: echo "${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_BASE64 }}"
| base64 -d
> android/service_account.json
if: ${{ steps.skip.outputs.no == 'true'
&& matrix.store == 'Google Play' }}
- name: Validate iOS application against App Store
run: fastlane validate
env:
APP_STORE_CONNECT_API_KEY_KEY_ID: ${{ secrets.APP_STORE_IDENTIFIER }}
APP_STORE_CONNECT_API_KEY_ISSUER_ID: ${{ secrets.APP_STORE_ISSUER }}
APP_STORE_CONNECT_API_KEY_KEY_FILEPATH: ${{ runner.temp }}/AuthKey_${{ secrets.APP_STORE_IDENTIFIER }}.p8
working-directory: ios/
if: ${{ steps.skip.outputs.no == 'true'
&& matrix.store == 'App Store' }}
- name: Validate Android application against Google Play
run: fastlane validate
working-directory: android/
if: ${{ steps.skip.outputs.no == 'true'
&& matrix.store == 'Google Play' }}
- name: Cleanup App Store Connect key
run: rm -rf ${{ runner.temp }}/AuthKey_${{ secrets.APP_STORE_IDENTIFIER }}.p8
if: ${{ always()
&& matrix.store == 'App Store' }}
- name: Cleanup Google Service account
run: rm -rf android/service_account.json
if: ${{ always()
&& matrix.store == 'Google Play' }}
############
# Building #
############
appcast:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # for correct versioning via `git describe --tags`
- name: Parse semver versions from Git tag
id: semver
uses: actions-ecosystem/action-regex-match@v2
with:
text: ${{ github.ref }}
regex: '^refs/tags/v(((([0-9]+)\.[0-9]+)\.[0-9]+)(-.+)?)$'
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Fetch existing Appcast XMLs from gh-pages
run: git checkout origin/gh-pages -- appcast/
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
- run: mkdir -p appcast/
- run: rm -f appcast/appcast.xml
- run: make appcast.xml.item
env:
link: ${{ (startsWith(github.ref, 'refs/tags/v')
&& secrets.ARTIFACTS_STABLE)
|| secrets.ARTIFACTS_MAIN }}
notes: ${{ (!startsWith(github.ref, 'refs/tags/v')
&& secrets.APPCAST_NOTES)
|| '' }}
version: ${{ (startsWith(github.ref, 'refs/tags/v')
&& steps.semver.outputs.group1)
|| '' }}
- run: make appcast.xml
- uses: actions/upload-artifact@v4
with:
name: appcast-${{ github.run_number }}
path: appcast/
if-no-files-found: error
retention-days: 1
build:
strategy:
fail-fast: false
matrix:
platform:
- apk
- appbundle
- ipa
- macos
- web
- windows
runs-on: ${{ (contains('ipa macos', matrix.platform) && 'macos-latest')
|| (matrix.platform == 'windows' && 'windows-latest')
|| 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4
with:
# Unshallow the repository in order for `PubspecBuilder` and its
# `git describe` to work.
fetch-depth: 0
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VER }}
channel: stable
cache: true
- run: make flutter.pub
# Running `build_runner` here ensures `PubspecBuilder` and its
# `git describe` command returns the valid result without possible
# `-dirty` part, that may happen during FCM configuration.
- run: make flutter.gen overwrite=true
if: ${{ contains('apk appbundle ipa web', matrix.platform) }}
- uses: actions/setup-java@v4
with:
distribution: temurin # Temurin is cached on GitHub Actions Runners.
java-version: 21
cache: gradle
if: ${{ contains('apk appbundle', matrix.platform) }}
- name: Configure FCM (Firebase Cloud Messaging)
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ runner.temp }}/service_account.json
run: |
set -ex
npm install -g firebase-tools
dart pub global activate flutterfire_cli
echo '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}' \
> ${{ runner.temp }}/service_account.json
make fcm.conf project-id=${{ secrets.FCM_PROJECT_ID }} \
platforms="android,ios,web" \
web-id=${{ secrets.FCM_WEB_APP_ID }} \
bundle-id=${{ secrets.FCM_BUNDLE_ID }}
if: ${{ contains('apk appbundle ipa web', matrix.platform) }}
- name: Configure FCM (Firebase Cloud Messaging) service worker
run: echo '${{ secrets.GOOGLE_SERVICES_JS }}'
> web/firebase-messaging-sw.js
if: ${{ matrix.platform == 'web' }}
- name: Parse semver versions from Git tag
id: semver
uses: actions-ecosystem/action-regex-match@v2
with:
text: ${{ github.ref }}
regex: '^refs/tags/v(((([0-9]+)\.[0-9]+)\.[0-9]+)(-.+)?)$'
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
# TODO: Remove `profile=yes`, when self-hosted Sentry supports source
# maps reading.
- run: make flutter.build platform=${{ matrix.platform }} profile=yes
dart-env='SOCAPP_FCM_VAPID_KEY=${{ secrets.FCM_VAPID_KEY }}
SOCAPP_LINK_PREFIX=${{ startsWith(github.ref, 'refs/tags/v') && secrets.LINK_STABLE || secrets.LINK_MAIN }}
SOCAPP_SENTRY_DSN=${{ startsWith(github.ref, 'refs/tags/v') && secrets.SENTRY_DSN_STABLE || secrets.SENTRY_DSN_MAIN }}'
if: ${{ matrix.platform == 'web' }}
- name: Prepare Android signing resources
run: |
echo "${{ secrets.ANDROID_KEYSTORE }}" | base64 -d \
> android/app/keystore.jks
echo "${{ secrets.ANDROID_PROPERTIES }}" \
> android/key.properties
if: ${{ contains('apk appbundle', matrix.platform) }}
- name: Prepare iOS signing resources
run: |
# Install Codemagic CLI Tools.
python3 -m venv $RUNNER_TEMP/venv
source $RUNNER_TEMP/venv/bin/activate
python3 -m pip install codemagic-cli-tools
# Create variables.
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
KEY_PATH=$RUNNER_TEMP/cert_key
# Import certificate and its key from secrets.
echo -n "$BUILD_CERTIFICATE_BASE64" \
| base64 --decode -o $CERTIFICATE_PATH
openssl pkcs12 -in $CERTIFICATE_PATH \
-nodes -nocerts -passin pass:$P12_PASSWORD \
| openssl rsa -out $KEY_PATH
# Initialize keychain.
keychain initialize
# Fetch the signing resources from App Store Connect.
app-store-connect fetch-signing-files \
$(xcode-project detect-bundle-id) \
--platform IOS \
--type IOS_APP_STORE \
--certificate-key=@file:$KEY_PATH \
--create
keychain add-certificates
# Export `export_options.plist` file to sign iOS application with.
xcode-project use-profiles
env:
APP_STORE_CONNECT_ISSUER_ID: ${{ secrets.APP_STORE_ISSUER }}
APP_STORE_CONNECT_KEY_IDENTIFIER: ${{ secrets.APP_STORE_IDENTIFIER }}
APP_STORE_CONNECT_PRIVATE_KEY: ${{ secrets.APP_STORE_KEY }}
BUILD_CERTIFICATE_BASE64: ${{ secrets.IOS_SIGNING_CERTIFICATE }}
P12_PASSWORD: ${{ secrets.IOS_SIGNING_CERTIFICATE_PASSWORD }}
if: ${{ matrix.platform == 'ipa' }}
# TODO: Add the following `split-debug-info`, when self-hosted Sentry
# supports debug symbols:
# split-debug-info=${{ contains('web windows', matrix.platform) && 'no' || 'yes' }}
# TODO: Use `split-debug-info` for Windows once Sentry supports it:
# https://github.com/getsentry/sentry-dart/issues/433
# https://github.com/getsentry/sentry-dart/issues/896
- run: make flutter.build platform=${{ matrix.platform }}
export-options="$HOME/export_options.plist"
dart-env='SOCAPP_HTTP_URL=${{ secrets.BACKEND_URL }}
SOCAPP_HTTP_PORT=${{ secrets.BACKEND_PORT }}
SOCAPP_WS_URL=${{ secrets.BACKEND_WS }}
SOCAPP_WS_PORT=${{ secrets.BACKEND_PORT }}
SOCAPP_APPCAST_URL=${{ startsWith(github.ref, 'refs/tags/v') && secrets.APPCAST_STABLE || secrets.APPCAST_MAIN }}
SOCAPP_DOWNLOADS_DOWNLOADABLE=${{ !startsWith(github.ref, 'refs/tags/v') || !contains('appbundle ipa', matrix.platform) }}
SOCAPP_LINK_PREFIX=${{ startsWith(github.ref, 'refs/tags/v') && secrets.LINK_STABLE || secrets.LINK_MAIN }}
SOCAPP_SENTRY_DSN=${{ startsWith(github.ref, 'refs/tags/v') && secrets.SENTRY_DSN_STABLE || secrets.SENTRY_DSN_MAIN }}
SOCAPP_USER_AGENT_VERSION=${{ steps.semver.outputs.group1 }}'
if: ${{ matrix.platform != 'web' }}
- name: Read generated `pubspec.g.dart`
id: pubspec
uses: juliangruber/read-file-action@v1
with:
path: lib/pubspec.g.dart
- name: Ensure no `-dirty` in `pubspec.g.dart` version
run: ${{ contains(steps.pubspec.outputs.content, '-dirty')
&& 'exit 1'
|| 'exit 0' }}
- name: Codesign macOS application
run: |
set -ex
# Create variables.
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
PP_PATH=$RUNNER_TEMP/build_pp.provisionprofile
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# Import certificate and provisioning profile from secrets.
echo -n "$BUILD_CERTIFICATE_BASE64" \
| base64 --decode -o $CERTIFICATE_PATH
echo -n "$BUILD_PROVISION_PROFILE_BASE64" \
| base64 --decode -o $PP_PATH
# Create temporary keychain.
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
# Import certificate to keychain.
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A \
-t cert -f pkcs12 -k $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple: \
-k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
security list-keychain -d user -s $KEYCHAIN_PATH
# Apply provisioning profile.
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
# Codesign the application.
codesign --deep --force --verbose --options=runtime --timestamp \
--sign "$BUILD_CERTIFICATE_IDENTITY" \
--entitlements macos/Runner/Release.entitlements \
build/macos/Build/Products/Release/*.app
codesign --verify -vvvv build/macos/Build/Products/Release/*.app
env:
BUILD_CERTIFICATE_BASE64: ${{ secrets.MACOS_SIGNING_CERTIFICATE }}
BUILD_CERTIFICATE_IDENTITY: ${{ secrets.MACOS_SIGNING_IDENTITY }}
BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.MACOS_PROVISION_PROFILE }}
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
P12_PASSWORD: ${{ secrets.MACOS_SIGNING_CERTIFICATE_PASSWORD }}
if: ${{ matrix.platform == 'macos' }}
- name: Parse application name from Git repository name
id: app
uses: actions-ecosystem/action-regex-match@v2
with:
text: ${{ github.repository }}
regex: '^${{ github.repository_owner }}/(.+)$'
- run: mkdir artifacts/
- run: mv build/app/outputs/flutter-apk/app-release.apk
artifacts/${{ steps.app.outputs.group1 }}-android.apk
if: ${{ matrix.platform == 'apk' }}
- run: mv build/app/outputs/bundle/release/app-release.aab
artifacts/${{ steps.app.outputs.group1 }}-android.aab
if: ${{ matrix.platform == 'appbundle' }}
- run: mv build/ios/ipa/messenger.ipa
artifacts/${{ steps.app.outputs.group1 }}-ios.ipa
if: ${{ matrix.platform == 'ipa' }}
- run: mkdir -p dist/ && mv *.app dist/ # `.app` executable is a folder itself
working-directory: build/macos/Build/Products/Release/
if: ${{ matrix.platform == 'macos' }}
- name: Notarize and staple macOS application
run: |
set -ex
mkdir -p .cache/
cd build/macos/Build/Products/Release/dist/
zip -r ${{ github.workspace }}/.cache/app.zip . --symlinks
cd ${{ github.workspace }}/
xcrun notarytool submit .cache/app.zip \
--apple-id "$APPLE_ID" \
--team-id $TEAM_ID \
--password $PASSWORD \
--wait
xcrun stapler staple build/macos/Build/Products/Release/dist/*.app
env:
APPLE_ID: ${{ secrets.NOTARY_APPLE_ID }}
TEAM_ID: ${{ secrets.NOTARY_TEAM_ID }}
PASSWORD: ${{ secrets.NOTARY_PASSWORD }}
if: ${{ matrix.platform == 'macos'
&& (github.ref == 'refs/heads/main'
|| startsWith(github.ref, 'refs/tags/v')) }}
- uses: thedoctor0/zip-release@0.7.6
with:
custom: ${{ (runner.os == 'Windows' && ' ') || '--symlinks' }} # preserve symlinks, instead of copying files
filename: ${{ github.workspace }}/artifacts/${{ steps.app.outputs.group1 }}-${{ matrix.platform }}.zip
directory: ${{ (matrix.platform == 'macos'
&& 'build/macos/Build/Products/Release/dist')
|| (matrix.platform == 'windows'
&& 'build/windows/x64/runner/Release')
|| 'build/web'}}
if: ${{ contains('macos web windows', matrix.platform) }}
- name: Generate SHA256 checksums
run: ${{ (runner.os == 'Windows'
&& 'forfiles /M *.zip /C "cmd /c sha256sum @file > @file.sha256sum"')
|| (runner.os == 'macOS'
&& 'ls -1 | xargs -I {} sh -c "shasum -a 256 {} > {}.sha256sum"')
|| 'ls -1 | xargs -I {} sh -c "sha256sum {} > {}.sha256sum"' }}
working-directory: artifacts/
- name: Show generated SHA256 checksums
run: ${{ (runner.os == 'Windows'
&& 'type *.sha256sum')
|| 'cat *.sha256sum' }}
working-directory: artifacts/
- uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.platform }}-${{ github.run_number }}
path: artifacts/
if-no-files-found: error
retention-days: 1
# TODO: Uncomment when self-hosted Sentry supports debug symbols:
# Globstar is supported in Bash 4.0+, `macos-latest` runner uses Bash 3.2.
# - name: Prepare `*.dSYM` debug symbols
# run: find build -name "*.dSYM" -prune -exec mv {} debug/ \;
# if: ${{ contains('ipa macos', matrix.platform) }}
# - name: Prepare debug web source maps
# run: |
# shopt -s globstar
# mkdir -p debug/
# mv build/web/**/*.map debug/
# cd build/web && cp --parents **/*.js ../../debug/
# if: ${{ matrix.platform == 'web' }}
# - uses: thedoctor0/zip-release@0.7.6
# with:
# filename: ${{ github.workspace }}/debug-${{ matrix.platform }}.zip
# directory: debug
# if: ${{ contains('apk appbundle ipa macos web', matrix.platform) }}
# - uses: actions/upload-artifact@v4
# with:
# name: debug-${{ matrix.platform }}-${{ github.run_number }}
# path: debug-${{ matrix.platform }}.zip
# if-no-files-found: error
# retention-days: 1
# if: ${{ contains('apk appbundle ipa macos web', matrix.platform) }}
- name: Cleanup Android signing resources
run: rm -rf android/app/keystore.jks
android/key.properties
if: ${{ always()
&& runner.os != 'Windows' }} # we don't use any for Windows anyway
- name: Cleanup iOS codesign resources
run: |
source $RUNNER_TEMP/venv/bin/activate
security delete-keychain $(keychain get-default)
keychain use-login
if: ${{ always()
&& matrix.platform == 'ipa' }}
- name: Cleanup macOS codesign resources
run: |
rm -rf ~/Library/MobileDevice/Provisioning\ Profiles/build_pp.provisionprofile
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db
if: ${{ always()
&& matrix.platform == 'macos' }}
build-linux:
name: build (linux)
runs-on: ubuntu-latest
# Pin glibc to 2.31 version for better compatibility.
container: debian:bullseye
steps:
# `debian:bullseye` doesn't include Git in its `PATH`, which is required
# by `PubspecBuilder`.
- name: Install Git
run: |
set -ex
apt-get update
apt-get install -y git
- uses: actions/checkout@v4
with:
# Unshallow the repository in order for `PubspecBuilder` and its
# `git describe` to work.
fetch-depth: 0
- run: apt-get update -y
- run: apt-get install -y
ninja-build
libunwind-dev
libgtk-3-dev
libpulse-dev
libmpv-dev
libcurl4-openssl-dev
mpv
jq
curl
git
make
procps
cmake
clang
zip
- run: git config --global --add safe.directory '*'
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VER }}
channel: stable
cache: true
- name: Parse semver versions from Git tag
id: semver
uses: actions-ecosystem/action-regex-match@v2
with:
text: ${{ github.ref }}
regex: '^refs/tags/v(((([0-9]+)\.[0-9]+)\.[0-9]+)(-.+)?)$'
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
- run: make flutter.pub
# TODO: Use `split-debug-info` when Sentry supports Linux debug symbols.
# https://github.com/getsentry/sentry-dart/issues/433
- run: make flutter.build platform=linux
dart-env='SOCAPP_HTTP_URL=${{ secrets.BACKEND_URL }}
SOCAPP_HTTP_PORT=${{ secrets.BACKEND_PORT }}
SOCAPP_WS_URL=${{ secrets.BACKEND_WS }}
SOCAPP_WS_PORT=${{ secrets.BACKEND_PORT }}
SOCAPP_APPCAST_URL=${{ startsWith(github.ref, 'refs/tags/v') && secrets.APPCAST_STABLE || secrets.APPCAST_MAIN }}
SOCAPP_LINK_PREFIX=${{ startsWith(github.ref, 'refs/tags/v') && secrets.LINK_STABLE || secrets.LINK_MAIN }}
SOCAPP_SENTRY_DSN=${{ startsWith(github.ref, 'refs/tags/v') && secrets.SENTRY_DSN_STABLE || secrets.SENTRY_DSN_MAIN }}
SOCAPP_USER_AGENT_VERSION=${{ steps.semver.outputs.group1 }}'
- name: Read generated `pubspec.g.dart`
id: pubspec
uses: juliangruber/read-file-action@v1
with:
path: lib/pubspec.g.dart
- name: Ensure no `-dirty` in `pubspec.g.dart` version
run: ${{ contains(steps.pubspec.outputs.content, '-dirty')
&& 'exit 1'
|| 'exit 0' }}
- name: Parse application name from Git repository name
id: app
uses: actions-ecosystem/action-regex-match@v2
with:
text: ${{ github.repository }}
regex: '^${{ github.repository_owner }}/(.+)$'
- run: mkdir artifacts/
- uses: thedoctor0/zip-release@0.7.6
with:
filename: ${{ github.workspace }}/artifacts/${{ steps.app.outputs.group1 }}-linux.zip
directory: build/linux/x64/release/bundle
- name: Generate SHA256 checksums
run: ${{ 'ls -1 | xargs -I {} sh -c "sha256sum {} > {}.sha256sum"' }}
working-directory: artifacts/
- name: Show generated SHA256 checksums
run: ${{ 'cat *.sha256sum' }}
working-directory: artifacts/
- uses: actions/upload-artifact@v4
with:
name: build-linux-${{ github.run_number }}
path: artifacts/
if-no-files-found: error
retention-days: 1
dartdoc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # for correct versioning via `git describe --tags`
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VER }}
channel: stable
cache: true
- run: make flutter.pub
- run: make docs.dart clean=yes
- uses: actions/upload-artifact@v4
with:
name: dartdoc-${{ github.run_number }}
path: doc/api/
if-no-files-found: error
if: ${{ github.ref == 'refs/heads/main'
|| startsWith(github.ref, 'refs/tags/v') }}
docker:
needs: ["appcast", "build", "build-linux"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: actions/download-artifact@v4
with:
name: build-web-${{ github.run_number }}
- run: mkdir -p build/web/
- run: unzip *.zip -d build/web/
- run: mkdir -p build/web/artifacts/
- uses: actions/download-artifact@v4
with:
name: build-apk-${{ github.run_number }}
path: build/web/artifacts/
- uses: actions/download-artifact@v4
with:
name: build-appbundle-${{ github.run_number }}
path: build/web/artifacts/
- uses: actions/download-artifact@v4
with:
name: build-ipa-${{ github.run_number }}
path: build/web/artifacts/
- uses: actions/download-artifact@v4
with:
name: build-linux-${{ github.run_number }}
path: build/web/artifacts/
- uses: actions/download-artifact@v4
with:
name: build-macos-${{ github.run_number }}
path: build/web/artifacts/
- uses: actions/download-artifact@v4
with:
name: build-windows-${{ github.run_number }}
path: build/web/artifacts/
# TODO: Refactor when actions/download-artifact#176 is implemented:
# https://github.com/actions/download-artifact/issues/176
- uses: actions/download-artifact@v4
with:
name: appcast-${{ github.run_number }}
path: appcast/
if: ${{ startsWith(github.ref, 'refs/tags/v')
|| github.ref == 'refs/heads/main' }}
- run: cp appcast/appcast.xml
build/web/appcast.xml
if: ${{ startsWith(github.ref, 'refs/tags/v')
|| github.ref == 'refs/heads/main' }}
- run: make docker.image no-cache=yes
tag=build-${{ github.run_number }}
- run: make docker.tar to-file=.cache/image.tar
tags=build-${{ github.run_number }}
- uses: actions/upload-artifact@v4
with:
name: docker-${{ github.run_number }}
path: .cache/image.tar
if-no-files-found: error
retention-days: 1
###########
# Testing #
###########
test-e2e:
name: test (E2E)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # for correct versioning via `git describe --tags`
- name: Retrieve commit messages
id: commit
run: |
echo "messages=$(git log --grep='\[debug\]' \
--grep='\[trace\]' \
--format=%s)" \
>> $GITHUB_OUTPUT
- name: Determine log level
id: log
run: |
echo "level=${{ (contains(steps.commit.outputs.messages, '[debug]')
&& 'debug')
|| (contains(steps.commit.outputs.messages, '[trace]')
&& 'trace')
|| 'info' }}"
>> $GITHUB_OUTPUT
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VER }}
channel: stable
cache: true
- name: Login to private E2E container registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.E2E_REGISTRY }}
username: ${{ secrets.E2E_USER }}
password: ${{ secrets.E2E_PASS }}
- run: make flutter.pub
- name: Prepare E2E environment
uses: SpicyPizza/create-envfile@v2
with:
envkey_COMPOSE_BACKEND: ${{ secrets.E2E_BACKEND }}
envkey_COMPOSE_COCKROACHDB: ${{ secrets.E2E_COCKROACH }}
envkey_COMPOSE_PUSH_FCM_SA_KEY: ${{ secrets.E2E_FCM_SA_KEY }}
envkey_COMPOSE_PUSH_APNS_TEAM_ID: ${{ secrets.E2E_APNS_TEAM_ID }}
envkey_COMPOSE_PUSH_APNS_KEY_ID: ${{ secrets.E2E_APNS_KEY_ID }}
envkey_COMPOSE_PUSH_APNS_TOPIC: ${{ secrets.E2E_APNS_TOPIC }}
envkey_COMPOSE_PUSH_APNS_PRIVATE_KEY: ${{ secrets.E2E_APNS_PRIVATE_KEY }}
envkey_COMPOSE_FRONTEND_IMAGE: nginx
envkey_COMPOSE_FRONTEND_TAG: stable-alpine
envkey_COMPOSE_FILESERVER: ${{ secrets.E2E_FILESERVER }}
envkey_COMPOSE_PROJECT_NAME: messenger
fail_on_empty: true
- run: mkdir build/
# Run `chromedriver` and `make test.e2e` simultaneously, as `web-server`
# device doesn't produce any progression logs, yet `--enable-chrome-logs`
# passed to the `chromedriver` does.
#
# Use `grep` to remove the meaningless logs from the output.
- uses: nanasess/setup-chromedriver@v2
- run: |
chromedriver --port=4444 --enable-chrome-logs \
--disable-dev-shm-usage \
2> >(grep -v -E '${{ join(fromJson(env.OMIT), '|') }}') &
make test.e2e start-app=yes device=web-server pull=yes no-cache=yes \
dart-env='SOCAPP_LOG_LEVEL=${{ steps.log.outputs.level }}'
env:
OMIT: |
[
":INFO:CONSOLE\\(53103\\)] ",
"\"Got object store box in database",
"\\[CONFIG\\]: Remote configuration fetch failed"
]
# Grant permissions to `.cache/` dir created in the previous step, since
# `hashFile` may fail: https://github.com/actions/runner/issues/449
- run: sudo chmod -R 755 .cache/
test-unit:
name: test (unit)
# TODO: Use `ubuntu-latest` when actions/runner-images#11279 is fixed:
# https://github.com/actions/runner-images/issues/11279
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # for correct versioning via `git describe --tags`
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VER }}
channel: stable
cache: true
- run: make flutter.pub
- run: make test.unit
#############
# Releasing #
#############
docker-push:
name: docker push
if: ${{ github.ref == 'refs/heads/main'
|| startsWith(github.ref, 'refs/tags/v') }}
needs:
- copyright
- dartanalyze
- dartdoc
- dartfmt
- docker
- test-e2e
- test-unit
strategy:
fail-fast: false
matrix:
registry: ["ghcr.io"]
runs-on: ubuntu-latest
steps:
# Skip if this is fork and no credentials are provided.
- id: skip
run: echo "no=${{ !(
github.repository_owner != 'team113'
&& ((matrix.registry == 'quay.io'
&& secrets.QUAYIO_ROBOT_USER == '')
|| (matrix.registry == 'docker.io'
&& secrets.DOCKERHUB_BOT_USER == ''))
) }}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
if: ${{ steps.skip.outputs.no == 'true' }}
- uses: actions/download-artifact@v4
with:
name: docker-${{ github.run_number }}
path: .cache/
if: ${{ steps.skip.outputs.no == 'true' }}
- run: make docker.untar from-file=.cache/image.tar
if: ${{ steps.skip.outputs.no == 'true' }}
- name: Login to ${{ matrix.registry }} container registry
uses: docker/login-action@v3
with:
registry: ${{ matrix.registry }}
username: ${{ (matrix.registry == 'docker.io'
&& secrets.DOCKERHUB_BOT_USER)
|| (matrix.registry == 'quay.io'
&& secrets.QUAYIO_ROBOT_USER)
|| github.repository_owner }}
password: ${{ (matrix.registry == 'docker.io'
&& secrets.DOCKERHUB_BOT_PASS)
|| (matrix.registry == 'quay.io'
&& secrets.QUAYIO_ROBOT_TOKEN)
|| secrets.GITHUB_TOKEN }}
if: ${{ steps.skip.outputs.no == 'true' }}
- name: Parse semver versions from Git tag
id: semver
uses: actions-ecosystem/action-regex-match@v2
with:
text: ${{ github.ref }}
regex: '^refs/tags/v(((([0-9]+)\.[0-9]+)\.[0-9]+)(-.+)?)$'
if: ${{ steps.skip.outputs.no == 'true'
&& startsWith(github.ref, 'refs/tags/v') }}
- name: Form version Docker tags
id: tags
uses: actions/github-script@v7
with:
result-encoding: string
script: |
let versions = '${{ steps.semver.outputs.group1 }}';
if ('${{ steps.semver.outputs.group5 }}' === '') {
versions += ',${{ steps.semver.outputs.group3 }}';
if ('${{ steps.semver.outputs.group4 }}' !== '0') {
versions += ',${{ steps.semver.outputs.group4 }}';
}
versions += ',latest';
}
return versions;
if: ${{ steps.skip.outputs.no == 'true'
&& startsWith(github.ref, 'refs/tags/v') }}
- run: make docker.tags of=build-${{ github.run_number }}
registries=${{ matrix.registry }}
tags=${{ (startsWith(github.ref, 'refs/tags/v')
&& steps.tags.outputs.result)
|| 'edge' }}
if: ${{ steps.skip.outputs.no == 'true' }}
- run: make docker.push
registries=${{ matrix.registry }}
tags=${{ (startsWith(github.ref, 'refs/tags/v')
&& steps.tags.outputs.result)
|| 'edge' }}
if: ${{ steps.skip.outputs.no == 'true' }}
# On GitHub Container Registry README is automatically updated on pushes.
- name: Update README on Docker Hub
uses: christian-korneck/update-container-description-action@v1
with:
provider: dockerhub
destination_container_repo: ${{ github.repository }}
readme_file: README.md
env:
DOCKER_USER: ${{ secrets.DOCKERHUB_BOT_USER }}
DOCKER_PASS: ${{ secrets.DOCKERHUB_BOT_PASS }}
if: ${{ steps.skip.outputs.no == 'true'
&& matrix.registry == 'docker.io' }}
- name: Update README on Quay.io
uses: christian-korneck/update-container-description-action@v1
with:
provider: quay
destination_container_repo: ${{ matrix.registry }}/${{ github.repository }}
readme_file: README.md
env:
DOCKER_APIKEY: ${{ secrets.QUAYIO_API_TOKEN }}
if: ${{ steps.skip.outputs.no == 'true'
&& matrix.registry == 'quay.io' }}
helm-push:
name: helm push
if: ${{ startsWith(github.ref, 'refs/tags/helm/') }}
needs: ["helm-lint"]
strategy:
max-parallel: 1