-
-
Notifications
You must be signed in to change notification settings - Fork 11
247 lines (234 loc) · 9.46 KB
/
deployment.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
name: Deployment
on:
release:
types: [ published ]
jobs:
security_hardening:
name: Check security hardening
runs-on: ubuntu-latest
steps:
- name: Clone the repository
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
- name: Ensure SHA pinned actions
uses: zgosalvez/github-actions-ensure-sha-pinned-actions@8877889a5717dad0b139f1d2925689aa68f88a43
verify_clean_release:
name: Verify a clean release
needs: security_hardening
runs-on: ubuntu-latest
steps:
- name: The release should not have any existing assets
if: join(github.event.release.assets, '') != ''
run: |
echo "::error::The "${{ github.event.release.name }}" release has preexisting assets. This workflow will not be able to upload build files as release assets."
exit 1
testing:
name: Run ${{ matrix.category }} testing
needs: verify_clean_release
runs-on: ubuntu-latest
strategy:
matrix:
category: [static, unit, widget]
fail-fast: false
steps:
- name: Clone the repository
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
path: code
- name: Get Flutter version
id: get-flutter-version
uses: zgosalvez/github-actions-get-flutter-version-env@b5f12dbe2915d60c827758258d6193df1dacca1d
with:
pubspec-file-path: code/pubspec.yaml
- name: Cache Flutter
id: flutter-cache
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353
with:
path: flutter
key: ${{ env.cache-name }}-ubuntu-latest-${{ steps.get-flutter-version.outputs.version }}-${{ hashFiles('code/pubspec.lock') }}
restore-keys: |
${{ env.cache-name }}-ubuntu-latest-${{ steps.get-flutter-version.outputs.version }}-
${{ env.cache-name }}-ubuntu-latest-
${{ env.cache-name }}-
env:
cache-name: flutter-cache
- name: Clone the Flutter repository
if: steps.flutter-cache.outputs.cache-hit != 'true'
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
repository: flutter/flutter
ref: ${{ steps.get-flutter-version.outputs.version }}
path: flutter
- name: Add the flutter tool to the path
run: |
echo "$GITHUB_WORKSPACE/flutter/bin" >> $GITHUB_PATH
echo "$GITHUB_WORKSPACE/flutter/bin/cache/dart-sdk/bin" >> $GITHUB_PATH
- name: Populate the Flutter tool's cache of binary artifacts
if: steps.flutter-cache.outputs.cache-hit != 'true'
run: |
flutter config --no-analytics
flutter precache
- name: Get Flutter packages
run: flutter pub get
working-directory: code
# static testing
- name: Analyze Flutter
if: matrix.category == 'static'
uses: zgosalvez/github-actions-analyze-dart@bc72307ba08e59e62f4d6e5ae311cc464dc0f296
with:
fail-on-warnings: true
working-directory: code
# unit testing
- name: Run Flutter ${{ matrix.category }} tests
if: matrix.category != 'static'
run: flutter test --no-pub test/${{ matrix.category }}s
working-directory: code
build:
name: Build the ${{ matrix.file }} file
needs: testing
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
file: apk
asset-content-type: application/java-archive
- os: ubuntu-latest
file: aab
asset-content-type: application/zip
- os: macos-latest
file: ipa
asset-content-type: application/octet-stream
fail-fast: false
env:
FLUTTER_DEBUG_INFO_PATH: build/app/outputs/symbols
steps:
- name: Check matrix
if: ${{ !(matrix.file == 'apk' && github.event.release.prerelease) || ((matrix.file == 'aab' || matrix.file == 'ipa') && !github.event.release.prerelease) }}
run: exit
- name: Clone the repository
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
path: code
- name: Get Flutter version
id: get-flutter-version
uses: zgosalvez/github-actions-get-flutter-version-env@b5f12dbe2915d60c827758258d6193df1dacca1d
with:
pubspec-file-path: code/pubspec.yaml
- name: Cache Flutter
id: flutter-cache
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353
with:
path: flutter
key: ${{ env.cache-name }}-${{ matrix.os }}-${{ steps.get-flutter-version.outputs.version }}-${{ hashFiles('code/pubspec.lock') }}
restore-keys: |
${{ env.cache-name }}-${{ matrix.os }}-${{ steps.get-flutter-version.outputs.version }}-
${{ env.cache-name }}-${{ matrix.os }}-
${{ env.cache-name }}-
env:
cache-name: flutter-cache
- name: Clone the Flutter repository
if: steps.flutter-cache.outputs.cache-hit != 'true'
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
with:
repository: flutter/flutter
ref: ${{ steps.get-flutter-version.outputs.version }}
path: flutter
- name: Add the flutter tool to the path
run: |
echo "$GITHUB_WORKSPACE/flutter/bin" >> $GITHUB_PATH
echo "$GITHUB_WORKSPACE/flutter/bin/cache/dart-sdk/bin" >> $GITHUB_PATH
- name: Populate the Flutter tool's cache of binary artifacts
if: steps.flutter-cache.outputs.cache-hit != 'true'
run: |
flutter config --no-analytics
flutter precache
- name: Get Flutter packages
run: flutter pub get
working-directory: code
# all
- name: Parse the release tag
id: parse-release-tag
run: | # remove the leading "v"
VERSION=${{ github.event.release.tag_name }}
echo "::set-output name=version::${VERSION#v}"
working-directory: code
- name: Set the app version
uses: microsoft/variable-substitution@6287962da9e5b6e68778dc51e840caa03ca84495
with:
files: 'code/pubspec.yaml'
env:
version: ${{ steps.parse-release-tag.outputs.version }}
# apk
- name: Build an Android APK file
if: matrix.file == 'apk'
run: |
flutter build apk --obfuscate --split-debug-info=$FLUTTER_DEBUG_INFO_PATH
mv build/app/outputs/flutter-apk/app-release.apk ../app.apk
mv build/app/outputs/mapping/release/mapping.txt ../apk-mapping.txt
working-directory: code
# aab
- name: Build an Android App Bundle file
if: matrix.file == 'aab'
run: |
flutter build appbundle --obfuscate --split-debug-info=$FLUTTER_DEBUG_INFO_PATH
mv build/app/outputs/bundle/release/app-release.aab ../app.aab
mv build/app/outputs/mapping/release/mapping.txt ../aab-mapping.txt
working-directory: code
# apk/aab
- name: Upload the artifacts — ${{ matrix.file }}-mapping.txt file
if: matrix.file == 'apk' || matrix.file == 'aab'
uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074
with:
name: ${{ matrix.file }}-mapping.txt
path: ${{ matrix.file }}-mapping.txt
- name: Upload the release assets — ${{ matrix.file }}-mapping.txt file
if: matrix.file == 'apk' || matrix.file == 'aab'
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ matrix.file }}-mapping.txt
asset_name: ${{ matrix.file }}-mapping.txt
asset_content_type: text/plain
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ipa
- name: Build an iOS App Store Package file
if: matrix.file == 'ipa'
run: |
flutter build ios --no-codesign --obfuscate --split-debug-info=$FLUTTER_DEBUG_INFO_PATH
echo "::warning::TODO: fastlane export_ipa"
echo "TODO: mv code/build/app/outputs/ipa/app.ipa ../app.ipa"
working-directory: code
# all
- name: Archive Flutter ${{ matrix.file }} symbols
run: zip --recurse-paths ${{ github.workspace }}/code/flutter-${{ matrix.file }}-symbols.zip .
working-directory: code/${{ env.FLUTTER_DEBUG_INFO_PATH }}
- name: Upload the artifacts — flutter-${{ matrix.file }}-symbols.zip file
uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074
with:
name: flutter-${{ matrix.file }}-symbols.zip
path: code/flutter-${{ matrix.file }}-symbols.zip
- name: Upload the release assets — flutter-${{ matrix.file }}-symbols.zip file
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: code/flutter-${{ matrix.file }}-symbols.zip
asset_name: flutter-${{ matrix.file }}-symbols.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload the artifacts — ${{ matrix.file }} file
uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074
with:
name: app.${{ matrix.file }}
path: app.${{ matrix.file }}
if-no-files-found: error
- name: Upload the release assets — ${{ matrix.file }} file
uses: actions/upload-release-asset@e8f9f06c4b078e705bd2ea027f0926603fc9b4d5
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: app.${{ matrix.file }}
asset_name: app.${{ matrix.file }}
asset_content_type: ${{ matrix.asset-content-type }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}