-
Notifications
You must be signed in to change notification settings - Fork 0
927 lines (802 loc) · 33.3 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
name: CI
on:
workflow_dispatch:
inputs:
flavor:
type: choice
description: "Flavor"
default: "dev"
required: false
options:
- "dev"
- "staging"
- "prod"
run_tests:
description: "Run tests"
default: true
required: false
type: boolean
push:
branches:
- "**"
- "!gh-pages"
tags:
- "v*"
env:
FLUTTER_CHANNEL: "stable"
FLUTTER_VERSION: "3.19"
FLAVOR: ""
# https://github.com/transferwise/sanitize-branch-name/blob/main/action.yml
BRANCH_NAME: $(echo -n ${{ github.head_ref || github.ref_name }} | tr "/" "-")
# Needed to deploy to GitHub Pages
permissions:
contents: write
jobs:
flutter_test:
name: Run flutter test and analyze
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Variables
run: |
echo "Inputs: ${{ toJSON(github.event.inputs) }}"
is_tag_string=${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}
is_tag=false
if [ "$is_tag_string" = "true" ]; then
is_tag=true
fi
flavor=""
if $is_tag; then
flavor="prod"
elif [ -z "${{ github.event.inputs.flavor }}" ]; then
flavor="dev"
else
flavor="${{ github.event.inputs.flavor }}"
fi
echo "FLAVOR=$flavor" >> $GITHUB_ENV
echo "FLAVOR=$flavor"
echo "BRANCH_NAME=${{ env.BRANCH_NAME }}" >> $GITHUB_ENV
echo "BRANCH_NAME=${{ env.BRANCH_NAME }}"
- name: Print Variables
run: |
echo "Flutter Channel: ${{ env.FLUTTER_CHANNEL }}"
echo "Flutter Version: ${{ env.FLUTTER_VERSION }}"
echo "Current Flavor: ${{ env.FLAVOR }}"
echo "Current Branch: ${{ env.BRANCH_NAME }}"
- name: Install and set Flutter version
uses: subosito/flutter-action@v2
if: github.event.inputs.run_tests == 'true' || github.event.inputs.run_tests == null
with:
channel: ${{env.FLUTTER_CHANNEL}}
flutter-version: ${{env.FLUTTER_VERSION}}
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:"
architecture: x64
- name: Check Flutter Version
if: github.event.inputs.run_tests == 'true' || github.event.inputs.run_tests == null
run: flutter --version
# Make environment variables available to the melos generate script.
#
# The environment variables need to be defined in the repository secrets
- name: Load Environment Variables
uses: oNaiPs/secrets-to-env-action@v1
if: github.event.inputs.run_tests == 'true' || github.event.inputs.run_tests == null
with:
secrets: ${{ toJSON(secrets) }}
- name: Activate Melos
if: github.event.inputs.run_tests == 'true' || github.event.inputs.run_tests == null
run: dart pub global activate melos ^4.1.0
- name: Bootstrap Melos
if: github.event.inputs.run_tests == 'true' || github.event.inputs.run_tests == null
run: melos bootstrap
# Comment out this task if you don't want to enforce formatting.
- name: Verify Formatting
if: github.event.inputs.run_tests == 'true' || github.event.inputs.run_tests == null
run: melos run verify_format
- name: Annotate PR
if: github.event.inputs.run_tests == 'true' || github.event.inputs.run_tests == null
uses: invertase/[email protected]
with:
fatal-infos: false
fatal-warnings: false
annotate-only: true
# custom-lint: true
- name: Run Dart Analyzer
if: github.event.inputs.run_tests == 'true' || github.event.inputs.run_tests == null
run: melos run analyze
- name: Run Custom Lints
if: github.event.inputs.run_tests == 'true' || github.event.inputs.run_tests == null
run: melos run custom_lint
# Project needs to have tests in test/ and a dependency on
# package:flutter_test for this step to succeed.
#
# Each package in the packages/ directory should have its own
# test/ directory with tests for that package.
- name: Run Tests
if: github.event.inputs.run_tests == 'true' || github.event.inputs.run_tests == null
run: melos run test
- name: Upload Coverage to Codecov
if: github.event_name == 'push' && !startsWith(github.event.ref, 'refs/tags/v')
uses: codecov/codecov-action@v3
with:
files: "**/*/lcov.info"
build_ios:
name: Build Flutter for iOS (Without Signing)
needs: [flutter_test]
runs-on: macos-14
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Variables
run: |
echo "Inputs: ${{ toJSON(github.event.inputs) }}"
is_tag_string=${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}
is_tag=false
if [ "$is_tag_string" = "true" ]; then
is_tag=true
fi
flavor=""
if $is_tag; then
flavor="prod"
elif [ -z "${{ github.event.inputs.flavor }}" ]; then
flavor="dev"
else
flavor="${{ github.event.inputs.flavor }}"
fi
echo "FLAVOR=$flavor" >> $GITHUB_ENV
echo "FLAVOR=$flavor"
echo "BRANCH_NAME=${{ env.BRANCH_NAME }}" >> $GITHUB_ENV
echo "BRANCH_NAME=${{ env.BRANCH_NAME }}"
- name: Install and set Flutter version
uses: subosito/flutter-action@v2
with:
channel: ${{env.FLUTTER_CHANNEL}}
flutter-version: ${{env.FLUTTER_VERSION}}
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:"
architecture: x64
- name: Check Flutter Version
run: flutter --version
# Make environment variables available to the melos generate script.
#
# The environment variables need to be defined in the repository secrets
- name: Load Environment Variables
uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
- name: Activate Melos
run: dart pub global activate melos ^4.1.0
- name: Bootstrap Melos
run: melos bootstrap
# Zip into IPA from here:
# https://gist.github.com/devhammed/617d920b7ee886591a46c22633ab0093
- name: Build Flutter IPA
run: |
flutter build ios --release --no-codesign --dart-define FLUTTER_APP_FLAVOR=${{ env.FLAVOR }}
cd build/ios/iphoneos
mkdir Payload
cd Payload
ln -s ../Runner.app
cd ..
zip -r app-release.ipa Payload
mv app-release.ipa flutter_boolean_template-${{ env.BRANCH_NAME }}-ios.ipa
- name: Upload IPA
uses: actions/upload-artifact@v4
with:
name: flutter_boolean_template-${{ env.BRANCH_NAME }}-ios
path: build/ios/iphoneos/flutter_boolean_template-*.ipa
- name: Release IPA
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
uses: ncipollo/release-action@v1
with:
artifacts: build/ios/iphoneos/flutter_boolean_template-*.ipa
allowUpdates: true
omitBodyDuringUpdate: true
# build_ios_with_signing:
# name: Build Flutter for iOS (Signed)
# needs: [flutter_test]
# runs-on: macos-14
# steps:
# - name: Checkout repository
# uses: actions/checkout@v4
# # From github documentation
#
# - name: Set Variables
# run: |
# echo "Inputs: ${{ toJSON(github.event.inputs) }}"
#
# is_tag_string=${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}
# is_tag=false
# if [ "$is_tag_string" = "true" ]; then
# is_tag=true
# fi
#
# flavor=""
# if $is_tag; then
# flavor="prod"
# elif [ -z "${{ github.event.inputs.flavor }}" ]; then
# flavor="dev"
# else
# flavor="${{ github.event.inputs.flavor }}"
# fi
# echo "FLAVOR=$flavor" >> $GITHUB_ENV
# echo "FLAVOR=$flavor"
# echo "BRANCH_NAME=${{ env.BRANCH_NAME }}" >> $GITHUB_ENV
# echo "BRANCH_NAME=${{ env.BRANCH_NAME }}"
#
# - name: Install the Apple certificate, provisioning profile, and Firebase google services
# env:
# BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
# P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
# BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
# KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
# run: |
# # create variables
# CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
# PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
# KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
# # import certificate and provisioning profile from secrets
# echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode --output $CERTIFICATE_PATH
# echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode --output $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 list-keychain -d user -s $KEYCHAIN_PATH
# # apply provisioning profile
# mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
# cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
#
# - name: Install and set Flutter version
# uses: subosito/flutter-action@v2
# with:
# channel: ${{env.FLUTTER_CHANNEL}}
# flutter-version: ${{env.FLUTTER_VERSION}}
# cache: true
# cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
# cache-path: '${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:'
# architecture: x64
# - run: flutter pub get
# - run: flutter clean
# # Zip into IPA from here:
# # https://gist.github.com/devhammed/617d920b7ee886591a46c22633ab0093
# - name: Build Flutter IPA
# run: |
# flutter build ios --release --no-codesign --dart-define FLUTTER_APP_FLAVOR=${{ env.FLAVOR }}
# cd build/ios/iphoneos
# mkdir Payload
# cd Payload
# ln -s ../Runner.app
# cd ..
# zip -r app-release.ipa Payload
# mv app-release.ipa flutter_boolean_template-${{ env.BRANCH_NAME }}-ios.ipa
# - name: Upload IPA
# uses: actions/upload-artifact@v4
# with:
# path: build/ios/iphoneos/flutter_boolean_template-*.ipa
# - name: Release IPA
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
# uses: ncipollo/release-action@v1
# with:
# artifacts: build/ios/iphoneos/flutter_boolean_template-*.ipa
# allowUpdates: true
# omitBodyDuringUpdate: true
build_android:
name: Build Flutter for Android
needs: [flutter_test]
runs-on: macos-14
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Variables
run: |
echo "Inputs: ${{ toJSON(github.event.inputs) }}"
is_tag_string=${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}
is_tag=false
if [ "$is_tag_string" = "true" ]; then
is_tag=true
fi
flavor=""
if $is_tag; then
flavor="prod"
elif [ -z "${{ github.event.inputs.flavor }}" ]; then
flavor="dev"
else
flavor="${{ github.event.inputs.flavor }}"
fi
echo "FLAVOR=$flavor" >> $GITHUB_ENV
echo "FLAVOR=$flavor"
echo "BRANCH_NAME=${{ env.BRANCH_NAME }}" >> $GITHUB_ENV
echo "BRANCH_NAME=${{ env.BRANCH_NAME }}"
- name: Setup Java JDK
uses: actions/[email protected]
with:
distribution: "temurin"
java-version: "18"
- name: Install and set Flutter version
uses: subosito/flutter-action@v2
with:
channel: ${{env.FLUTTER_CHANNEL}}
flutter-version: ${{env.FLUTTER_VERSION}}
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:"
architecture: x64
- name: Check Flutter Version
run: flutter --version
# Make environment variables available to the melos generate script.
#
# The environment variables need to be defined in the repository secrets
- name: Load Environment Variables
uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
- name: Activate Melos
run: dart pub global activate melos ^4.1.0
- name: Bootstrap Melos
run: melos bootstrap
- name: Build Android Split APK
run: |
flutter pub get
flutter build apk --release --split-per-abi --dart-define FLUTTER_APP_FLAVOR=${{ env.FLAVOR }}
cd build/app/outputs/flutter-apk
mv app-arm64-v8a-release.apk flutter_boolean_template-${{ env.BRANCH_NAME }}-android-arm64-v8a.apk
mv app-armeabi-v7a-release.apk flutter_boolean_template-${{ env.BRANCH_NAME }}-android-armeabi-v7a.apk
mv app-x86_64-release.apk flutter_boolean_template-${{ env.BRANCH_NAME }}-android-x86_64.apk
- name: Upload Split APKs
uses: actions/upload-artifact@v4
with:
name: flutter_boolean_template-${{ env.BRANCH_NAME }}-android-split
path: build/app/outputs/flutter-apk/flutter_boolean_template-*.apk
- name: Release Split APKs
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
uses: ncipollo/release-action@v1
with:
artifacts: build/app/outputs/flutter-apk/flutter_boolean_template-*.apk
allowUpdates: true
omitBodyDuringUpdate: true
- name: Build Universal APK
run: |
flutter pub get
flutter build apk --release --dart-define FLUTTER_APP_FLAVOR=${{ env.FLAVOR }}
cd build/app/outputs/flutter-apk
mv app-release.apk flutter_boolean_template-${{ env.BRANCH_NAME }}-android-universal.apk
- name: Upload Universal APK
uses: actions/upload-artifact@v4
with:
name: flutter_boolean_template-${{ env.BRANCH_NAME }}-android-universal
path: build/app/outputs/flutter-apk/flutter_boolean_template-${{ env.BRANCH_NAME }}-android-universal.apk
- name: Release Universal APKs
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
uses: ncipollo/release-action@v1
with:
artifacts: build/app/outputs/flutter-apk/flutter_boolean_template-${{ env.BRANCH_NAME }}-android-universal.apk
allowUpdates: true
omitBodyDuringUpdate: true
- name: Build Android App Bundle
run: |
flutter pub get
flutter build appbundle --release --dart-define FLUTTER_APP_FLAVOR=${{ env.FLAVOR }}
cd build/app/outputs/bundle/release
mv app-release.aab flutter_boolean_template-${{ env.BRANCH_NAME }}-android-appbundle.aab
- name: Upload Android App Bundle
uses: actions/upload-artifact@v4
with:
name: flutter_boolean_template-${{ env.BRANCH_NAME }}-android-appbundle
path: build/app/outputs/bundle/release/*.aab
- name: Release Android App Bundle
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
uses: ncipollo/release-action@v1
with:
artifacts: build/app/outputs/bundle/release/flutter_boolean_template-*.aab
allowUpdates: true
omitBodyDuringUpdate: true
build_windows:
name: Build Flutter for Windows x64
needs: [flutter_test]
runs-on: windows-latest
steps:
# Need to enable long paths for Windows because the forked version of go_router
# causes a long path error when building for Windows in CI
- name: Enable Git Long Paths
run: git config --system core.longpaths true
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Variables
run: |
$is_tag = "${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}"
$flavor = ""
if ($is_tag) {
$flavor = "prod"
}
elseif ([string]::IsNullOrEmpty("${{ github.event.inputs.flavor }}")) {
$flavor = "dev"
}
else {
$flavor = "${{ github.event.inputs.flavor }}"
}
"FLAVOR=$flavor" | Out-File -Append -LiteralPath $Env:GITHUB_ENV
Write-Output "FLAVOR=$flavor"
"BRANCH_NAME=${{ env.BRANCH_NAME }}" | Out-File -Append -LiteralPath $Env:GITHUB_ENV
Write-Output "BRANCH_NAME=${{ env.BRANCH_NAME }}"
shell: pwsh
- name: Print Variables
run: |
Write-Output "Current Flavor: ${{ env.FLAVOR }}"
- name: Install and set Flutter version
uses: subosito/flutter-action@v2
with:
channel: ${{env.FLUTTER_CHANNEL}}
flutter-version: ${{env.FLUTTER_VERSION}}
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:"
architecture: x64
- name: Check Flutter Version
run: flutter --version
# Make environment variables available to the melos generate script.
#
# The environment variables need to be defined in the repository secrets
- name: Load Environment Variables
uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
- name: Activate Melos
run: dart pub global activate melos ^4.1.0
- name: Bootstrap Melos
run: melos bootstrap
- name: Build Windows
run: flutter build windows --dart-define FLUTTER_APP_FLAVOR=${{ env.FLAVOR }}
- name: Build MSIX
run: |
dart run msix:create --build-windows false
cd build\windows\x64\runner\Release
mv flutter_boolean_template.msix flutter_boolean_template-${{ env.BRANCH_NAME }}-windows.msix
- name: Upload MSIX
uses: actions/upload-artifact@v4
with:
name: flutter_boolean_template-${{ env.BRANCH_NAME }}-windows
path: build/windows/x64/runner/Release/*.msix
- name: Release MSIX
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
uses: ncipollo/release-action@v1
with:
artifacts: build/windows/x64/runner/Release/flutter_boolean_template-*.msix
allowUpdates: true
omitBodyDuringUpdate: true
build_linux:
name: Build Flutter for Linux
needs: [flutter_test]
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Variables
run: |
echo "Inputs: ${{ toJSON(github.event.inputs) }}"
is_tag_string=${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}
is_tag=false
if [ "$is_tag_string" = "true" ]; then
is_tag=true
fi
flavor=""
if $is_tag; then
flavor="prod"
elif [ -z "${{ github.event.inputs.flavor }}" ]; then
flavor="dev"
else
flavor="${{ github.event.inputs.flavor }}"
fi
echo "FLAVOR=$flavor" >> $GITHUB_ENV
echo "FLAVOR=$flavor"
echo "BRANCH_NAME=${{ env.BRANCH_NAME }}" >> $GITHUB_ENV
echo "BRANCH_NAME=${{ env.BRANCH_NAME }}"
- name: Install and set Flutter version
uses: subosito/flutter-action@v2
with:
channel: ${{env.FLUTTER_CHANNEL}}
flutter-version: ${{env.FLUTTER_VERSION}}
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:"
architecture: x64
- name: Install Dependencies
run: |
sudo apt-get update -y
sudo apt-get install webkit2gtk-4.1 clang cmake ninja-build pkg-config libgtk-3-dev mpv libmpv-dev dpkg-dev
sudo apt install -y libfuse2
- name: Check Flutter Version
run: flutter --version
# Make environment variables available to the melos generate script.
#
# The environment variables need to be defined in the repository secrets
- name: Load Environment Variables
uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
- name: Activate Melos
run: dart pub global activate melos ^4.1.0
- name: Bootstrap Melos
run: melos bootstrap
- name: Build Linux
run: flutter build linux --release --dart-define FLUTTER_APP_FLAVOR=${{ env.FLAVOR }}
- name: Build AppImage
run: |
curl -JOL https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
chmod a+x appimagetool-x86_64.AppImage
mv appimagetool-x86_64.AppImage appimagetool
mv build/linux/x64/release/bundle/{flutter_boolean_template,AppRun}
cp linux/appimage/* build/linux/x64/release/bundle/
./appimagetool build/linux/x64/release/bundle/
mv *.AppImage build/flutter_boolean_template-${{ env.BRANCH_NAME }}-linux.AppImage
- name: Upload AppImage
uses: actions/upload-artifact@v4
with:
name: flutter_boolean_template-${{ env.BRANCH_NAME }}-linux-appimage
path: build/flutter_boolean_template-*.AppImage
- name: Release AppImage
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
uses: ncipollo/release-action@v1
with:
artifacts: build/flutter_boolean_template-*.AppImage
allowUpdates: true
omitBodyDuringUpdate: true
build_macos:
name: Build Flutter for MacOS
needs: [flutter_test]
runs-on: macos-14
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Variables
run: |
echo "Inputs: ${{ toJSON(github.event.inputs) }}"
is_tag_string=${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}
is_tag=false
if [ "$is_tag_string" = "true" ]; then
is_tag=true
fi
flavor=""
if $is_tag; then
flavor="prod"
elif [ -z "${{ github.event.inputs.flavor }}" ]; then
flavor="dev"
else
flavor="${{ github.event.inputs.flavor }}"
fi
echo "FLAVOR=$flavor" >> $GITHUB_ENV
echo "FLAVOR=$flavor"
echo "BRANCH_NAME=${{ env.BRANCH_NAME }}" >> $GITHUB_ENV
echo "BRANCH_NAME=${{ env.BRANCH_NAME }}"
- name: Install and set Flutter version
uses: subosito/flutter-action@v2
with:
channel: ${{env.FLUTTER_CHANNEL}}
flutter-version: ${{env.FLUTTER_VERSION}}
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:"
architecture: x64
- name: Check Flutter Version
run: flutter --version
# Make environment variables available to the melos generate script.
#
# The environment variables need to be defined in the repository secrets
- name: Load Environment Variables
uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
- name: Activate Melos
run: dart pub global activate melos ^4.1.0
- name: Bootstrap Melos
run: melos bootstrap
- name: Build MacOS
run: |
git config --global core.longpaths true
flutter pub get
flutter build macos --release --dart-define FLUTTER_APP_FLAVOR=${{ env.FLAVOR }}
- name: Build DMG
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
max_attempts: 3
retry_on: error
command: |
brew install create-dmg
create-dmg --volname flutter_boolean_template-${{ env.BRANCH_NAME }}-macos --window-pos 200 120 --window-size 800 450 --icon-size 100 --app-drop-link 600 185 flutter_boolean_template-${{ env.BRANCH_NAME }}-macos.dmg build/macos/Build/Products/Release/flutter_boolean_template.app
- name: Upload DMG
uses: actions/upload-artifact@v4
with:
name: flutter_boolean_template-${{ env.BRANCH_NAME }}-macos-dmg
path: "/Users/runner/work/flutter_boolean_template/flutter_boolean_template/*.dmg"
- name: Release DMG
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
uses: ncipollo/release-action@v1
with:
artifacts: /Users/runner/work/flutter_boolean_template/flutter_boolean_template/flutter_boolean_template-*.dmg
allowUpdates: true
omitBodyDuringUpdate: true
build_web:
name: Build Flutter for Web
needs: [flutter_test]
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set Variables
run: |
echo "Inputs: ${{ toJSON(github.event.inputs) }}"
is_tag_string=${{ github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') }}
is_tag=false
if [ "$is_tag_string" = "true" ]; then
is_tag=true
fi
flavor=""
if $is_tag; then
flavor="prod"
elif [ -z "${{ github.event.inputs.flavor }}" ]; then
flavor="dev"
else
flavor="${{ github.event.inputs.flavor }}"
fi
echo "FLAVOR=$flavor" >> $GITHUB_ENV
echo "FLAVOR=$flavor"
echo "BRANCH_NAME=${{ env.BRANCH_NAME }}" >> $GITHUB_ENV
echo "BRANCH_NAME=${{ env.BRANCH_NAME }}"
- name: Install and set Flutter version
uses: subosito/flutter-action@v2
with:
channel: ${{env.FLUTTER_CHANNEL}}
flutter-version: ${{env.FLUTTER_VERSION}}
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:"
- name: Check Flutter Version
run: flutter --version
# Make environment variables available to the melos generate script.
#
# The environment variables need to be defined in the repository secrets
- name: Load Environment Variables
uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
- name: Activate Melos
run: dart pub global activate melos ^4.1.0
- name: Bootstrap Melos
run: melos bootstrap
- name: Build Web
run: |
flutter pub get
flutter build web --dart-define FLUTTER_APP_FLAVOR=${{ env.FLAVOR }} --release --web-renderer=canvaskit
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: flutter_boolean_template-${{ env.BRANCH_NAME }}-web
path: build/web
deploy_web:
name: Deploy Flutter Web to GitHub Pages
runs-on: ubuntu-latest
needs: [build_web]
environment:
name: github-pages
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
contents: read # to find the issue number from the commit
pull-requests: write # to find the issue number from the pr and leave a comment
issues: write # to leave a comment on the issue
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name == 'push' && !startsWith(github.event.ref, 'refs/tags/v')
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install and set Flutter version
if: github.actor != 'dependabot[bot]'
uses: subosito/flutter-action@v2
with:
channel: ${{env.FLUTTER_CHANNEL}}
flutter-version: ${{env.FLUTTER_VERSION}}
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:"
- name: Get branch name
id: branch-name
if: github.actor != 'dependabot[bot]'
uses: tj-actions/branch-names@v8
- name: Check Flutter Version
if: github.actor != 'dependabot[bot]'
run: flutter --version
# Make environment variables available to the melos generate script.
#
# The environment variables need to be defined in the repository secrets
- name: Load Environment Variables
if: github.actor != 'dependabot[bot]'
uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
- name: Activate Melos
if: github.actor != 'dependabot[bot]'
run: dart pub global activate melos ^4.1.0
- name: Bootstrap Melos
if: github.actor != 'dependabot[bot]'
run: melos bootstrap
- name: Build Web
if: github.actor != 'dependabot[bot]'
run: |
flutter pub get
flutter build web --dart-define FLUTTER_APP_FLAVOR=staging --release --web-renderer=canvaskit --base-href="/${{ github.event.repository.name }}/${{ steps.branch-name.outputs.current_branch }}/"
- name: Deploy to GitHub Pages 🚀
if: github.actor != 'dependabot[bot]'
uses: JamesIves/github-pages-deploy-action@releases/v4
id: deployment
with:
# PAT required to trigger gh_pages_readme.yml workflow
token: ${{ secrets.PAT }}
branch: gh-pages # The branch the action should deploy to.
folder: build/web # The folder the action should deploy.
target-folder: "${{ steps.branch-name.outputs.current_branch }}"
# Ref: https://github.com/orgs/community/discussions/27071
- name: Find PR Number
uses: actions/github-script@v6
id: get_pr_number
if: github.actor != 'dependabot[bot]' && steps.deployment.outputs.deployment-status == 'success'
with:
script: |
if (context.issue.number) {
// Return issue number if present
return context.issue.number;
} else {
// Otherwise return issue number from commit
const comment = (
await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
})
).data[0];
if (comment != null) {
return comment.number;
}
return null;
}
result-encoding: string
- name: Get PR State
uses: actions/github-script@v6
id: get_pr_state
if: github.actor != 'dependabot[bot]' && steps.get_pr_number.outputs.result != 'null' && steps.deployment.outputs.deployment-status == 'success'
with:
script: |
return (
await github.rest.issues.get({
issue_number: ${{ steps.get_pr_number.outputs.result }},
owner: context.repo.owner,
repo: context.repo.repo,
})
).data.state;
result-encoding: string
- name: Find Comment
uses: peter-evans/find-comment@v3
id: comment
if: github.actor != 'dependabot[bot]' && steps.get_pr_number.outputs.result != 'null' && steps.deployment.outputs.deployment-status == 'success'
with:
issue-number: ${{ steps.get_pr_number.outputs.result }}
body-includes: Deployed to GitHub Pages 🚀
comment-author: github-actions[bot]
- name: Link Deployment in Pull Request Comment
if: github.actor != 'dependabot[bot]' && steps.get_pr_number.outputs.result != 'null' && steps.deployment.outputs.deployment-status == 'success' && steps.get_pr_state.outputs.result == 'open' && steps.comment.outputs.comment-id == ''
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: ${{ steps.get_pr_number.outputs.result }},
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Deployed to GitHub Pages 🚀: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ steps.branch-name.outputs.current_branch }}/'
});