This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
282 lines (258 loc) · 8.91 KB
/
build.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
name: Build & Lint
on:
push:
pull_request:
# schedule:
# - cron: '0 4 * * *'
env:
JAVA_VERSION: 12.x
FLUTTER_CHANNEL: stable
FLUTTER_VERSION: 2.0.x
jobs:
install:
name: Install Flutter & dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install Java
uses: actions/setup-java@v1
with:
java-version: ${{ env.JAVA_VERSION }}
- name: Install Flutter
uses: subosito/flutter-action@v1
with:
channel: ${{ env.FLUTTER_CHANNEL }}
flutter-version: ${{ env.FLUTTER_VERSION }}
# App
# - name: "app: Install dependencies"
# working-directory: ./app
# run: flutter pub get
# - name: "app: Run code generator(s)"
# working-directory: ./app
# run: |
# flutter pub run intl_utils:generate
# flutter pub run build_runner build
# - name: "app: Remove obsolete files"
# working-directory: ./app
# run: rm -rf ./.dart_tool/pub/bin/build_runner
- name: Persist current state
uses: actions/upload-artifact@v1
with:
name: source
path: .
app-lint:
name: 'app: lint'
needs: install
runs-on: ubuntu-latest
if: 'false'
steps:
- name: Install Java
uses: actions/setup-java@v1
with:
java-version: ${{ env.JAVA_VERSION }}
- name: Install Flutter
uses: subosito/flutter-action@v1
with:
channel: ${{ env.FLUTTER_CHANNEL }}
flutter-version: ${{ env.FLUTTER_VERSION }}
- name: Checkout source
uses: actions/download-artifact@v1
with:
name: source
path: .
- name: 'Install dependencies'
working-directory: ./app
run: flutter pub get
- name: Run linter
working-directory: ./app
run: flutter analyze > flutter_analyze_report.txt
continue-on-error: true
- name: Install ruby
uses: actions/setup-ruby@v1
if: github.event_name == 'pull_request'
with:
ruby-version: '2.6'
- name: Install ruby gems
working-directory: ./app
run: |
gem install bundler
bundle config set without 'documentation'
bundle install
if: github.event_name == 'pull_request'
- name: Run danger on generated report
working-directory: ./app
run: |
gem install danger --version ">= 6.0.0"
danger --dangerfile=Dangerfile --danger_id="danger-pr"
if: github.event_name == 'pull_request'
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
api-test:
name: 'api: tests'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: ${{ env.JAVA_VERSION }}
- uses: subosito/flutter-action@v1
with:
channel: ${{ env.FLUTTER_CHANNEL }}
flutter-version: ${{ env.FLUTTER_VERSION }}
- run: dart pub get
working-directory: ./api
- run: dart pub run build_runner build
working-directory: ./api
# Limit concurrency to prevent 429 errors.
- run: dart pub run test --concurrency 1
working-directory: ./api
env:
SC_AT_TEACHER_EMAIL: ${{ secrets.API_TEST_TEACHER_EMAIL }}
SC_AT_TEACHER_PASSWORD: ${{ secrets.API_TEST_TEACHER_PASSWORD }}
SC_AT_STUDENT_EMAIL: ${{ secrets.API_TEST_STUDENT_EMAIL }}
SC_AT_STUDENT_PASSWORD: ${{ secrets.API_TEST_STUDENT_PASSWORD }}
build-app:
name: 'app: build'
needs: install
runs-on: ubuntu-latest
strategy:
matrix:
flavor: ['sc', 'sc_test', 'brb', 'n21', 'nbc_audit', 'open', 'thr']
fail-fast: false
if: 'false'
steps:
- name: Install Java
uses: actions/setup-java@v1
with:
java-version: ${{ env.JAVA_VERSION }}
- name: Install Flutter
uses: subosito/flutter-action@v1
with:
channel: ${{ env.FLUTTER_CHANNEL }}
flutter-version: ${{ env.FLUTTER_VERSION }}
- name: Checkout source
uses: actions/download-artifact@v1
with:
name: source
path: .
- name: 'Install dependencies'
working-directory: ./app
run: flutter pub get
- working-directory: ./app
# https://github.com/flutter/flutter/issues/58247
run: |
flutter build apk --target=lib/main_${{ matrix.flavor }}.dart --flavor=${{ matrix.flavor }} --debug
flutter build apk --target=lib/main_${{ matrix.flavor }}.dart --flavor=${{ matrix.flavor }}
env:
RELEASE_USE_DEBUG_KEY: true
- name: Upload APK as artifact
uses: actions/upload-artifact@v1
with:
name: apk-${{ matrix.flavor }}
path: app/build/app/outputs/apk/${{ matrix.flavor }}/release
# TODO(JonasWanke): enable screenshots when this issue is fixed: https://github.com/flutter/flutter/issues/36244
# generate-screenshots:
# name: Generate screenshots
# needs: install
# # We have to use macOS for hardware acceleration on Android emulators
# runs-on: macos-10.15
# strategy:
# matrix:
# flavor: ["sc"]
# fail-fast: false
# steps:
# - name: Install Java 12
# uses: actions/setup-java@v1
# with:
# java-version: ${{ env.JAVA_VERSION }}
# - name: Install Flutter
# uses: subosito/flutter-action@v1
# with:
# channel: ${{ env.FLUTTER_CHANNEL }}
# flutter-version: ${{ env.FLUTTER_VERSION }}
# - name: Checkout source
# uses: actions/download-artifact@v1
# with:
# name: source
# path: .
# - name: Install Java 10
# uses: actions/setup-java@v1
# with:
# java-version: 10
# - name: Create virtual device
# run: |
# ~/Library/Android/sdk/tools/bin/sdkmanager "system-images;android-28;default;x86"
# echo no | ~/Library/Android/sdk/tools/bin/avdmanager --verbose create avd --force --name "Pixel_XL" --package "system-images;android-28;default;x86" --device "pixel_xl"
# env:
# JDK_JAVA_OPTIONS: "--add-modules java.xml.bind"
# - name: Install screenshots package
# run: |
# brew update && brew install imagemagick
# flutter pub global activate screenshots
# - name: Take screenshots
# run: flutter pub global run screenshots:main -v -f sc
# - name: Upload screenshots as artifact
# uses: actions/upload-artifact@v1
# with:
# name: screenshots-${{ matrix.flavor }}
# path: android/fastlane/metadata/android
# - uses: actions/upload-artifact@v1
# with:
# name: tmp-screenshots
# path: /tmp/screenshots
app-deploy-canary:
name: 'app: deploy canary'
needs: install
runs-on: ubuntu-latest
strategy:
matrix:
flavor: ['sc']
fail-fast: false
# if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: 'false'
steps:
- name: Install Java 12
uses: actions/setup-java@v1
with:
java-version: ${{ env.JAVA_VERSION }}
- name: Install Flutter
uses: subosito/flutter-action@v1
with:
channel: ${{ env.FLUTTER_CHANNEL }}
flutter-version: ${{ env.FLUTTER_VERSION }}
- name: Checkout source
uses: actions/download-artifact@v1
with:
name: source
path: .
- name: 'Install dependencies'
working-directory: ./app
run: flutter pub get
- name: Store Google Play credentials in a file
working-directory: ./app
run: echo "${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_KEY }}" | base64 --decode > ./android/fastlane/googlePlay-serviceAccount.json
- name: Store Google Play upload key in a file
working-directory: ./app
run: echo "${{ secrets.GOOGLE_PLAY_UPLOAD_KEY }}" | base64 --decode > ./android/upload.keystore.jks
- id: unicorn
name: Determine new version & generate changelog
uses: JonasWanke/unicorn@ad66dae
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
- name: Build AAB
working-directory: ./app
run: |
flutter build appbundle \
--flavor=sc \
--build-number=${{ steps.unicorn.outputs.versionCode }} \
--build-name=${{ steps.unicorn.outputs.version }}
env:
UPLOAD_KEY_STORE_PASSWORD: ${{ secrets.GOOGLE_PLAY_UPLOAD_KEY_STORE_PASSWORD }}
UPLOAD_KEY_KEY_PASSWORD: ${{ secrets.GOOGLE_PLAY_UPLOAD_KEY_KEY_PASSWORD }}
# Flutter doesn't find the generated .aab-file, but it should
continue-on-error: true
- name: Deploy to Google Play (internal track)
uses: maierj/[email protected]
with:
lane: uploadCanary
subdirectory: app/android