-
Notifications
You must be signed in to change notification settings - Fork 10
406 lines (351 loc) · 12.9 KB
/
kite.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
name: KiteApp
on:
push:
pull_request: { branches: [master] }
jobs:
# flutter pub get + flutter analyze
prebuild:
runs-on: ubuntu-latest
# case-insensitive
if: ${{ !contains(github.event.head_commit.message,'[NoCI]') }}
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: 3.7.0
channel: stable
cache: true
- name: 📌 Restore pub cache
uses: actions/cache@v3
with:
path: |
~/.pub-cache/
.dart_tool/
.packages
.flutter-plugins
.flutter-plugins-dependencies
pubspec.lock
key: pub-${{ github.ref }}-${{ github.sha }} # use ${{ hashFiles('pubspec.lock') }} when available
restore-keys: |
pub-${{ github.ref }}-
pub-
- name: 📌 Flutter Code Generate
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
flutter pub run flutter_native_splash:create
- name: 📌 Cache pub
uses: actions/cache@v3
with:
path: |
~/.pub-cache/
.dart_tool/
.packages
.flutter-plugins
.flutter-plugins-dependencies
pubspec.lock
key: pub-${{ github.ref }}-${{ github.sha }}
- name: 📌 Cache Workspace
uses: actions/cache@v3
with:
path: |
lib/
key: app-${{ github.ref }}-${{ github.sha }}
######################
# Android
#
build-Android:
needs: prebuild
runs-on: ubuntu-latest
if: github.repository == 'SIT-kite/kite-app'
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: 3.7.0
channel: stable
cache: true
- name: 📌 Restore pub cache
uses: actions/cache@v3
with:
path: |
~/.pub-cache/
.dart_tool/
.packages
.flutter-plugins
.flutter-plugins-dependencies
pubspec.lock
key: pub-${{ github.ref }}-${{ github.sha }}
- name: 📌 Restore Workspace
uses: actions/cache@v3
with:
path: |
lib/
key: app-${{ github.ref }}-${{ github.sha }}
- name: 🏗️ Build Apk (arm64,android-x64)
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
flutter build apk --split-per-abi --target-platform android-arm64,android-x64,android-arm
- uses: r0adkll/sign-android-release@v1
name: Sign APK
with:
releaseDirectory: build/app/outputs/flutter-apk
signingKeyBase64: ${{ secrets.APK_SIGN_JKS_BASE64 }}
alias: ${{ secrets.APK_SIGN_ALIAS }}
keyStorePassword: ${{ secrets.APK_SIGN_PASS }}
- name: 📌 Cache Build
uses: actions/cache@v3
with:
path: build/
key: apk-${{ github.ref }}-${{ github.sha }}
######################
# iOS
#
build-iOS:
# TODO: update to macos-12
runs-on: macos-latest
needs: prebuild
steps:
- uses: actions/checkout@v3
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
# TODO: Fix `Xcode 14 is not supported`
# xcode-version: '14.0.0'
- uses: subosito/flutter-action@v2
with:
flutter-version: 3.7.0
channel: stable
cache: true
- name: 📌 Restore pub cache
uses: actions/cache@v3
with:
path: |
~/.pub-cache/
.dart_tool/
.packages
.flutter-plugins
.flutter-plugins-dependencies
pubspec.lock
key: pub-${{ github.ref }}-${{ github.sha }}
- name: 📌 Restore Workspace
uses: actions/cache@v3
with:
path: |
lib/
key: app-${{ github.ref }}-${{ github.sha }}
- name: 🏗️ Build iOS
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
flutter build ios --no-codesign
build-Windows:
runs-on: windows-latest
needs: prebuild
steps:
- uses: nelonoel/[email protected]
- uses: benjlevesque/[email protected]
id: short-sha
with: { length: 7 }
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: 3.7.0
channel: stable
cache: true
- name: 🏗️ Build Windows
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
flutter build windows
- name: Upload Windows build file
uses: actions/upload-artifact@v3
with:
name: ${{ env.BRANCH_NAME }}-${{ env.SHA }}-windows-x86_64.zip
path: build/windows/runner/Release
######################
# macOS
#
build-macOS:
runs-on: macos-latest
needs: prebuild
env:
MACOS_APP_RELEASE_PATH: build/macos/Build/Products/Release
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: 3.7.0
channel: stable
cache: true
# Building
- name: 🏗️ Build macOS
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
flutter build macos --release
# Signing
- name: Codesign executable
env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
run: |
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
echo "Create Keychain"
security create-keychain -p SIT_KITE_PWD build.keychain
echo "Assign to Login Keychain"
security default-keychain -s build.keychain
echo "Unlock the Login Keychain"
security unlock-keychain -p SIT_KITE_PWD build.keychain
echo "Import certificate"
security import certificate.p12 -k build.keychain -P $MACOS_CERTIFICATE_PWD -T /usr/bin/codesign
echo "Set Key Partition"
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k SIT_KITE_PWD build.keychain
echo "Sign the app"
/usr/bin/codesign --force --deep -s MJGX7ZZ3AG ./$MACOS_APP_RELEASE_PATH/上应小风筝.app
- name: Upload macOS File
uses: actions/upload-artifact@v3
with:
name: ${{ env.BRANCH_NAME }}-${{ env.SHA }}-macos.zip
path: ./build/macos/Build/Products/Release/上应小风筝.app/
######################
# Linux
#
build-Linux:
runs-on: ubuntu-20.04
needs: prebuild
steps:
- uses: nelonoel/[email protected]
- uses: benjlevesque/[email protected]
id: short-sha
with: { length: 7 }
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with: { channel: stable, cache: true }
- run: |
sudo apt-get update -y
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
- name: 🏗️ Build Linux
run: |
flutter pub get
flutter pub run build_runner build --delete-conflicting-outputs
flutter build linux
- name: Upload linux build File
uses: actions/upload-artifact@v3
with:
name: ${{ env.BRANCH_NAME }}-${{ env.SHA }}-linux-x86_64.zip
path: build/linux/x64/release/bundle
# Upload apk
upload:
runs-on: ubuntu-latest
continue-on-error: true
if: |
github.ref == 'refs/heads/master' &&
github.repository == 'SIT-kite/kite-app'
needs:
- build-Android
steps:
- uses: nelonoel/[email protected]
- uses: benjlevesque/[email protected]
id: short-sha
with: { length: 7 }
- name: 📌 Get apk from cache
uses: actions/cache@v3
with:
path: build/
key: apk-${{ github.ref }}-${{ github.sha }}
- name: ✏️ Rename apk file
run: |
cd build/app/outputs/flutter-apk/
mv app-armeabi-v7a-release-signed.apk ${{ env.BRANCH_NAME }}-${{ env.SHA }}-armeabi-v7a-release-signed.apk
mv app-arm64-v8a-release-signed.apk ${{ env.BRANCH_NAME }}-${{ env.SHA }}-arm64-v8a-release-signed.apk
mv app-x86_64-release-signed.apk ${{ env.BRANCH_NAME }}-${{ env.SHA }}-x86_64-release-signed.apk
- name: Upload android-x86_64 apk artifact File
uses: actions/upload-artifact@v3
with:
name: ${{ env.BRANCH_NAME }}-${{ env.SHA }}-x86_64-release-signed.apk
path: build/app/outputs/flutter-apk/${{ env.BRANCH_NAME }}-${{ env.SHA }}-x86_64-release-signed.apk
- name: Upload android-armeabi-v7a apk artifact File
uses: actions/upload-artifact@v3
with:
name: ${{ env.BRANCH_NAME }}-${{ env.SHA }}-armeabi-v7a-release-signed.apk
path: build/app/outputs/flutter-apk/${{ env.BRANCH_NAME }}-${{ env.SHA }}-armeabi-v7a-release-signed.apk
- name: Upload android-arm64-v8a apk artifact File
uses: actions/upload-artifact@v3
with:
name: ${{ env.BRANCH_NAME }}-${{ env.SHA }}-arm64-v8a-release-signed.apk
path: build/app/outputs/flutter-apk/${{ env.BRANCH_NAME }}-${{ env.SHA }}-arm64-v8a-release-signed.apk
- name: 🤖 Upload apk by bot
uses: appleboy/[email protected]
with:
to: ${{ secrets.CHANNEL_CHAT_ID }}
token: ${{ secrets.BOT_TOKEN }}
document: build/app/outputs/flutter-apk/${{ env.BRANCH_NAME }}-${{ env.SHA }}-x86_64-release-signed.apk
message: "🚀 Android x86_64 Apk Build by Github Actions"
- name: 🤖 Upload apk by bot
uses: appleboy/[email protected]
with:
to: ${{ secrets.CHANNEL_CHAT_ID }}
token: ${{ secrets.BOT_TOKEN }}
document: build/app/outputs/flutter-apk/${{ env.BRANCH_NAME }}-${{ env.SHA }}-armeabi-v7a-release-signed.apk
message: "🚀 Android arm-v7a Apk Build by Github Actions"
- name: 🤖 Upload apk by bot
uses: appleboy/[email protected]
with:
to: ${{ secrets.CHANNEL_CHAT_ID }}
token: ${{ secrets.BOT_TOKEN }}
document: build/app/outputs/flutter-apk/${{ env.BRANCH_NAME }}-${{ env.SHA }}-arm64-v8a-release-signed.apk
message: "🚀 Android arm64-v8a Apk Build by Github Actions"
# Send notification
notification:
runs-on: ubuntu-latest
needs: [upload]
if: |
github.event_name != 'pull_request' &&
github.repository == 'SIT-kite/kite-app' &&
always()
steps:
- uses: technote-space/workflow-conclusion-action@v2
- uses: nelonoel/[email protected]
- uses: benjlevesque/[email protected]
id: short-sha
with: { length: 7 }
- name: 🤖 Build Success Notification
if: env.WORKFLOW_CONCLUSION == 'success'
uses: appleboy/[email protected]
with:
to: ${{ secrets.CHANNEL_CHAT_ID }}
token: ${{ secrets.BOT_TOKEN }}
format: markdown
message: |
🎉 [KiteApp](https://github.com/SIT-kite/kite-app) Build *${{ env.WORKFLOW_CONCLUSION }}*
Author: *${{ github.actor }}*
Message: *${{ github.event.head_commit.message }}*
Commit: [${{ env.SHA }}](https://github.com/${{ github.repository }}/commit/${{ env.SHA }})
Branch: *${{ env.BRANCH_NAME }}*
- name: 🤖 Build Fail Notification
if: env.WORKFLOW_CONCLUSION != 'success'
uses: appleboy/[email protected]
with:
to: ${{ secrets.CHANNEL_CHAT_ID }}
token: ${{ secrets.BOT_TOKEN }}
format: markdown
message: |
🔴 [KiteApp](https://github.com/SIT-kite/kite-app) Build *${{ env.WORKFLOW_CONCLUSION }}*
Author: *${{ github.actor }}*
Message: *${{ github.event.head_commit.message }}*
Commit: [${{ env.SHA }}](https://github.com/${{ github.repository }}/commit/${{ env.SHA }})
Branch: *${{ env.BRANCH_NAME }}*
- name: 🤖 PR Merged Notification
if: github.event.pull_request.merged == true && env.WORKFLOW_CONCLUSION == 'success'
uses: appleboy/[email protected]
with:
to: ${{ secrets.CHANNEL_CHAT_ID }}
token: ${{ secrets.BOT_TOKEN }}
format: markdown
message: |
🎉 [KiteApp](https://github.com/SIT-kite/kite-app) PR [#${{github.event.number}}](https://github.com/SIT-kite/kite-app/pull/${{github.event.number}}) Merged!
Author: *${{ github.actor }}*
Message: *${{ github.event.pull_request.title }}*
Branch: *${{ env.BRANCH_NAME }}*