-
Notifications
You must be signed in to change notification settings - Fork 0
186 lines (183 loc) · 7.13 KB
/
builds.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
name: Build for Android and iOS
run-name: >
${{ github.event.pull_request.title }} - ${{ github.workflow }} (#${{ github.run_number }}.${{ github.run_attempt }}) - ${{ github.event_name }} ${{ github.ref }} (from ${{ github.head_ref }} to ${{ github.base_ref }})
on:
push:
tags:
- '*'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
flutter_version: '3.24.3'
java_version: '11'
jobs:
version:
runs-on: ubuntu-latest
outputs:
versionCode: ${{ steps.version-code.outputs.versionCode }}
versionName: ${{ steps.version-name.outputs.versionName }}
steps:
- name: Outputs versionName
id: version-name
run: |
echo "versionName=${{ github.ref_name }}" >> $GITHUB_OUTPUT
- name: Calculate version code from tag and output it into versionCode
id: version-code
run: |
tag=${{ github.ref_name }}
delimiter=.
tag_array=(${tag//$delimiter/ })
major=${tag_array[0]}
minor=${tag_array[1]}
patch=${tag_array[2]}
version_code=$((major * 1000000 + minor * 1000 + patch))
echo "versionCode=$version_code" >> $GITHUB_OUTPUT
build-android:
runs-on: ubuntu-latest
needs: version
steps:
- uses: actions/checkout@v3
- name: Cache Flutter installation
uses: actions/cache@v3
with:
path: /opt/hostedtoolcache/flutter
key: ${{ runner.os }}-flutter-install-cache-${{ env.flutter_version }}
- name: Cache gradle dependencies
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Prepare workspace files - keystore and key.properties
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
KEY_PROPERTIES_BASE64: ${{ secrets.KEY_PROPERTIES_BASE64 }}
run: |
echo $KEYSTORE_BASE64 | base64 --decode > "${{ github.workspace }}/android/app/key.jks"
echo $KEY_PROPERTIES_BASE64 | base64 --decode > "${{ github.workspace }}/android/key.properties"
echo "key.properties file: $(ls -l "${{ github.workspace }}/android/key.properties")"
echo "key.jks file: $(ls -l "${{ github.workspace }}/android/app/key.jks")"
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
cache: 'gradle'
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.flutter_version }}
channel: 'stable'
- name: Cache Flutter packages
uses: actions/cache@v3
with:
path: | # get FLUTTER_ROOT from flutter-action
${{ env.FLUTTER_ROOT }}/.pub-cache
key: ${{ runner.os }}-pub-cache-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-pub-cache-
- uses: dart-lang/setup-dart@v1
with:
sdk: 'stable'
- run: flutter config --no-analytics
- run: flutter pub get
- name: build the environment
env:
ANDROID_APP_ID: ${{ secrets.ANDROID_APP_ID }}
ANDROID_BANNER_ID: ${{ secrets.ANDROID_BANNER_ID }}
ANDROID_NATIVE_ID: ${{ secrets.ANDROID_NATIVE_ID }}
IOS_APP_ID: ${{ secrets.IOS_APP_ID }}
IOS_BANNER_ID: ${{ secrets.IOS_BANNER_ID }}
IOS_NATIVE_ID: ${{ secrets.IOS_NATIVE_ID }}
TEST_ADS: ${{ secrets.TEST_ADS }}
run: dart tool/env.dart
- name: Activate flutter packages
run: |
flutter pub global activate intl_utils
- name: Generate files (freezed, json_serializable)
run: flutter pub run build_runner build --delete-conflicting-outputs
- name: Generate translations
run: |
flutter pub global run intl_utils:generate
- run: flutter test
- name: Build app bundle
env:
version_code: ${{ needs.version.outputs.versionCode }}
version_name: ${{ needs.version.outputs.versionName }}
run: |
echo "version_code: $version_code"
echo "version_name: $version_name"
flutter build appbundle --release --build-name $version_name --build-number $version_code
- name: Upload app bundle
uses: actions/upload-artifact@v3
with:
name: app-release-aab
path: |
build/app/outputs/bundle/release/app-release.aab
build/app/outputs/mapping/release/mapping.txt
- name: Use Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.3
bundler-cache: true # runs `bundle install` and caches installed gems automatically
- name: Deploy to Google Play - alpha track
run: bundle exec fastlane deploy
build-ios:
runs-on: macos-latest
needs: version
steps:
- uses: actions/checkout@v3
- name: Cache Flutter installation
uses: actions/cache@v3
with:
path: /Users/runner/hostedtoolcache/flutter
key: ${{ runner.os }}-flutter-install-cache-${{ env.flutter_version }}
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.flutter_version }}
channel: 'stable'
architecture: 'x64'
- uses: dart-lang/setup-dart@v1
with:
sdk: 'stable'
- name: Cache Flutter packages
uses: actions/cache@v3
with:
path: | # get FLUTTER_ROOT from flutter-action
${{ env.FLUTTER_ROOT }}/.pub-cache
key: ${{ runner.os }}-pub-cache-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
${{ runner.os }}-pub-cache-
- run: flutter config --no-analytics
- run: flutter --version
- run: flutter pub get
- name: build the environment
env:
ANDROID_APP_ID: ${{ secrets.ANDROID_APP_ID }}
ANDROID_BANNER_ID: ${{ secrets.ANDROID_BANNER_ID }}
ANDROID_NATIVE_ID: ${{ secrets.ANDROID_NATIVE_ID }}
IOS_APP_ID: ${{ secrets.IOS_APP_ID }}
IOS_BANNER_ID: ${{ secrets.IOS_BANNER_ID }}
IOS_NATIVE_ID: ${{ secrets.IOS_NATIVE_ID }}
TEST_ADS: ${{ secrets.TEST_ADS }}
run: dart tool/env.dart
- name: Generate files (freezed, json_serializable)
run: flutter pub run build_runner build --delete-conflicting-outputs
- name: Generate translations
run: |
flutter pub global activate intl_utils && flutter pub global run intl_utils:generate
- run: flutter test
- name: Build app bundle
env:
version_code: ${{ needs.version.outputs.versionCode }}
version_name: ${{ needs.version.outputs.versionName }}
run: |
echo "version_code: $version_code"
echo "version_name: $version_name"
flutter build ios --release --no-codesign --build-name $version_name --build-number $version_code
- name: Upload ios app
uses: actions/upload-artifact@v3
with:
name: app-release-ipa
path: build/ios/iphoneos/Runner.app