-
Notifications
You must be signed in to change notification settings - Fork 13
369 lines (289 loc) · 12.5 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
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
name: "build"
on:
push:
tags:
- "v*"
branches:
- "main"
pull_request:
branches:
- "main"
# https://docs.flutter.dev/development/tools/sdk/releases?tab=linux
env:
FLUTTER_VERSION: "3.3.10"
FLUTTER_BRANCH: "stable"
jobs:
android:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: "actions/checkout@v3"
with:
submodules: "recursive"
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: "Set version string for release"
run: echo DESTINY_VERSION=${{ github.ref_name }} >> $GITHUB_ENV
if: ${{ github.ref_type == 'tag' }}
- name: "Set version string for branch"
run: echo DESTINY_VERSION=${{ github.head_ref }} >> $GITHUB_ENV
if: ${{ github.ref_type != 'tag' }}
- name: "Setup flutter"
uses: subosito/flutter-action@v2
with:
# set fixed stable version, to avoid surprises, when flutter upgrades
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_BRANCH }}
- name: "Flutter info"
run: flutter doctor
- name: "Fetch flutter dependencies"
run: "flutter pub get"
- name: "Lint"
run: "flutter analyze --write analyze.output"
- name: "Style check"
run: "flutter format --set-exit-if-changed lib test"
- name: "Run tests"
run: "flutter test --machine --coverage | tee tests.output"
- uses: sonarsource/sonarqube-scan-action@master
if: github.ref_name == 'main' && github.event_name == 'push'
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
# We are building debug version APK which can be manually install, however it cannot be reused for upload to store
- name: "Build debug apk"
run: "flutter build apk lib/main_la.dart --dart-define version=${{ env.DESTINY_VERSION }} --build-name ${{ env.DESTINY_VERSION }} --debug"
- name: "Move apk"
run: mv ./build/app/outputs/flutter-apk/app-debug.apk destiny_android_${{ env.DESTINY_VERSION }}.apk
- name: "Copy apk"
uses: "actions/upload-artifact@v2"
with:
name: "destiny-android-${{ env.DESTINY_VERSION }}-unsigned"
path: destiny_android_${{ env.DESTINY_VERSION }}.apk
if-no-files-found: "error"
- uses: ncipollo/release-action@v1
with:
artifacts: destiny_android_${{ env.DESTINY_VERSION }}.apk
allowUpdates: true
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.ref_type == 'tag' }}
linux:
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: "actions/checkout@v3"
with:
submodules: "recursive"
- name: "Set version string for release"
run: echo DESTINY_VERSION=${{ github.ref_name }} >> $GITHUB_ENV
if: ${{ github.ref_type == 'tag' }}
- name: "Set version string for branch"
run: echo DESTINY_VERSION=${{ github.head_ref }} >> $GITHUB_ENV
if: ${{ github.ref_type != 'tag' }}
- name: "Setup flutter"
uses: subosito/flutter-action@v2
with:
# set fixed stable version, to avoid surprises, when flutter upgrades
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_BRANCH }}
- run: flutter --version
- name: "Fetch flutter dependencies"
run: "flutter pub get"
- name: "Lint"
run: "flutter analyze"
- name: "Style check"
run: "flutter format --set-exit-if-changed lib test"
- name: "Run tests"
run: "flutter test --coverage"
- name: "Enable linux builds"
run: "flutter config --enable-linux-desktop"
- name: "Install linux build dependencies"
run: "sudo apt update && sudo apt install ninja-build libgtk-3-dev libgtkmm-3.0-dev libfuse2"
- name: "Build for linux"
run: "flutter build linux lib/main_la.dart --dart-define version=${{ env.DESTINY_VERSION }}"
- name: "rpath workaround"
run: |
cd build/linux/x64/release/bundle
patchelf --remove-needed libbindings.so destiny
patchelf --add-needed libbindings.so destiny
patchelf --remove-needed libwormhole_william.so destiny
patchelf --add-needed libwormhole_william.so destiny
- name: "Prepare tarball"
run: |
cp -r build/linux/x64/release/bundle "destiny_linux_${{ env.DESTINY_VERSION }}"
tar -czf destiny_linux_${{ env.DESTINY_VERSION }}.tar.gz "destiny_linux_${{ env.DESTINY_VERSION }}"
- name: "Make AppImage"
run: |
./scripts/make_appimage.sh
mv Destiny-x86_64.AppImage destiny_linux_${{ env.DESTINY_VERSION }}.AppImage
- name: "Upload zip"
uses: "actions/upload-artifact@v2"
with:
name: "destiny-linux-${{ env.DESTINY_VERSION }}-unsigned"
path: "destiny_linux_${{ env.DESTINY_VERSION }}.tar.gz"
if-no-files-found: "error"
- name: "Upload AppImage"
uses: "actions/upload-artifact@v2"
with:
name: "destiny-linux-${{ env.DESTINY_VERSION }}-appimage-unsigned"
path: "destiny_linux_${{ env.DESTINY_VERSION }}.AppImage"
if-no-files-found: "error"
- uses: ncipollo/release-action@v1
with:
artifacts: "destiny_linux_${{ env.DESTINY_VERSION }}.tar.gz,destiny_linux_${{ env.DESTINY_VERSION }}.AppImage"
allowUpdates: true
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.ref_type == 'tag' }}
macos:
runs-on: macos-latest
steps:
- name: "Checkout"
uses: "actions/checkout@v3"
with:
submodules: "recursive"
- name: "Set version string for release"
run: echo DESTINY_VERSION=${{ github.ref_name }} >> $GITHUB_ENV
if: ${{ github.ref_type == 'tag' }}
- name: "Set version string for branch"
run: echo DESTINY_VERSION=${{ github.head_ref }} >> $GITHUB_ENV
if: ${{ github.ref_type != 'tag' }}
- name: "Setup flutter"
uses: subosito/flutter-action@v2
with:
# set fixed stable version, to avoid surprises, when flutter upgrades
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_BRANCH }}
- run: flutter --version
- name: "Fetch flutter dependencies"
run: "flutter pub get"
- name: "Lint"
run: "flutter analyze"
- name: "Style check"
run: "flutter format --set-exit-if-changed lib test"
- name: "Run tests"
run: "flutter test --coverage"
# TODO maybe this can be avoided by some project configuration,
# but running it locally doesn't change any files either.
- name: "Enable macos desktop builds"
run: "flutter config --enable-macos-desktop"
- name: "Build mac app"
run: "flutter build macos lib/main_la.dart --debug --dart-define version=${{ env.DESTINY_VERSION }} --build-name ${{ env.DESTINY_VERSION }}"
- name: "Install create-dmg"
run: "brew install create-dmg"
- name: "Create DMG"
run: "create-dmg --app-drop-link 0 0 destiny_macos_debug_${{ env.DESTINY_VERSION }}.dmg build/macos/Build/Products/Debug/Destiny.app"
- name: "Copy DMG"
uses: "actions/upload-artifact@v2"
with:
name: "destiny-macos-${{ env.DESTINY_VERSION }}-unsigned"
path: "./destiny_macos_debug_${{ env.DESTINY_VERSION }}.dmg"
if-no-files-found: "error"
- uses: ncipollo/release-action@v1
with:
artifacts: "./destiny_macos_debug_${{ env.DESTINY_VERSION }}.dmg"
allowUpdates: true
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.ref_type == 'tag' }}
ios:
runs-on: macos-latest
steps:
- name: "Checkout"
uses: "actions/checkout@v3"
with:
submodules: "recursive"
- name: "Set version string for release"
run: echo DESTINY_VERSION=${{ github.ref_name }} >> $GITHUB_ENV
if: ${{ github.ref_type == 'tag' }}
- name: "Set version string for branch"
run: echo DESTINY_VERSION=${{ github.head_ref }} >> $GITHUB_ENV
if: ${{ github.ref_type != 'tag' }}
- name: "Setup flutter"
uses: subosito/flutter-action@v2
with:
# set fixed stable version, to avoid surprises, when flutter upgrades
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_BRANCH }}
- run: flutter --version
- name: "Fetch flutter dependencies"
run: "flutter pub get"
# TODO remove the || true when this should be enforced
# Right now it is just informational
- name: "Lint"
run: "flutter analyze || true"
- name: "Style check"
run: "flutter format --set-exit-if-changed lib test"
- name: "Run tests"
run: "flutter test --coverage"
- name: "Build ios app (only for simulator)"
run: |
export GOROOT=`go env GOROOT`
flutter build ios lib/main_la.dart --debug --simulator --no-codesign --dart-define version=${{ env.DESTINY_VERSION }} --build-name ${{ env.DESTINY_VERSION }}
windows:
runs-on: windows-latest
steps:
- name: "Checkout"
uses: "actions/checkout@v3"
with:
submodules: "recursive"
- name: "Set version string for release"
run: 'echo "DESTINY_VERSION=${{ github.ref_name }}" >> $env:GITHUB_ENV'
if: ${{ github.ref_type == 'tag' }}
- name: "Set version string for branch"
run: 'echo "DESTINY_VERSION=${{ github.head_ref }}" >> $env:GITHUB_ENV'
if: ${{ github.ref_type != 'tag' }}
- name: "Setup flutter"
uses: subosito/flutter-action@v2
with:
# set fixed stable version, to avoid surprises, when flutter upgrades
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.FLUTTER_BRANCH }}
- run: flutter --version
- name: "Fetch flutter dependencies"
run: "flutter pub get"
- name: "Lint"
run: "flutter analyze"
- name: "Style check"
run: "flutter format --set-exit-if-changed lib test"
- name: "Run tests"
run: "flutter test --coverage"
- name: "Build windows"
run: "flutter build windows lib/main_la.dart --dart-define version=${{ env.DESTINY_VERSION }} --build-name ${{ env.DESTINY_VERSION }}"
- name: "Copy VC++ redistributables"
run: |
$vcredistpath = ((Get-ChildItem -Filter "msvcp140.dll" -Recurse "C:/Program Files/Microsoft Visual Studio/")[0] | Select -expand FullName) + "/.."
echo $vcredistpath
cp $vcredistpath/msvcp140.dll build/windows/runner/Release
cp $vcredistpath/vcruntime140.dll build/windows/runner/Release
cp $vcredistpath/vcruntime140_1.dll build/windows/runner/Release
- name: "Zip executable and libraries"
run: |
cp -r build/windows/runner/Release destiny_windows_${{ env.DESTINY_VERSION }}
7z a destiny_windows_${{ env.DESTINY_VERSION }}.zip "destiny_windows_${{ env.DESTINY_VERSION }}"
- name: "Create windows installer"
run: |
$version = ("${{ github.ref_name }}" -replace "v","") + ".0"
if ( -not ( $version -match "^\d+\.\d+\.\d+\.\d+$" ) ) {
echo "Invalid version for MSIX packaging: $version. Using 0.0.1.0 instead"
$version = "0.0.1.0"
}
echo y | flutter pub run msix:create --version $version --output-path . --build-windows false --output-name destiny_windows_${{ env.DESTINY_VERSION }}
- name: "Upload zip"
uses: "actions/upload-artifact@v2"
with:
name: "destiny-windows-${{ env.DESTINY_VERSION }}-unsigned"
path: "destiny_windows_${{ env.DESTINY_VERSION }}.zip"
if-no-files-found: "error"
- name: "Upload msix"
uses: "actions/upload-artifact@v2"
with:
name: "destiny-windows-${{ env.DESTINY_VERSION }}-unsigned-msix"
path: "destiny_windows_${{ env.DESTINY_VERSION }}.msix"
if-no-files-found: "error"
- uses: ncipollo/release-action@v1
with:
artifacts: "destiny_windows_${{ env.DESTINY_VERSION }}.zip,destiny_windows_${{ env.DESTINY_VERSION }}.msix"
allowUpdates: true
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.ref_type == 'tag' }}