-
Notifications
You must be signed in to change notification settings - Fork 80
529 lines (528 loc) · 18.6 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
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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
name: Flutter build
on: [push, release, pull_request]
jobs:
build-apk:
concurrency: ci-${{ github.ref }}
defaults:
run:
working-directory: app
runs-on: ubuntu-22.04
steps:
- name: ⬆️ Checkout
uses: actions/checkout@v3
- name: 🔧 Setup java
uses: actions/setup-java@v3
with:
java-version: "11"
distribution: "adopt"
- name: Get flutter version
run: |
FLUTTER_VERSION=$(cat FLUTTER_VERSION)
echo "FLUTTER_VERSION=${FLUTTER_VERSION}" >> $GITHUB_ENV
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'any'
- name: 📦 Get dependencies
run: |
flutter clean
flutter pub get
flutter doctor -v
- name: Import files
if: ${{ github.event_name != 'pull_request' }}
env:
KEY_JKS: ${{ secrets.KEY_JKS }}
KEY_PROPERTIES: ${{ secrets.KEY_PROPERTIES }}
run: |
cd android
if [[ -n "$KEY_PROPERTIES" ]] ; then echo "$KEY_PROPERTIES" | base64 --decode > key.properties ; fi
if [[ -n "$KEY_JKS" ]] ; then echo "$KEY_JKS" | base64 --decode > key.jks ; fi
#- run: flutter test
- name: 🏭 Build nightly
if: ${{ github.ref != 'refs/tags/stable' }}
run: |
flutter build apk -v --release --flavor development
cp build/app/outputs/flutter-apk/app-development-release.apk linwood-butterfly-android.apk
- name: 🏭 Build production
if: ${{ github.ref == 'refs/tags/stable' }}
run: |
flutter build apk -v --release --flavor production
cp build/app/outputs/flutter-apk/app-production-release.apk linwood-butterfly-android.apk
- name: Archive
uses: actions/upload-artifact@v3
with:
name: apk-build
path: app/linwood-butterfly-android.apk
build-windows:
runs-on: windows-2022
defaults:
run:
working-directory: app
steps:
- name: ⬆️ Checkout
uses: actions/checkout@v3
- name: Get flutter version
shell: bash
run: |
FLUTTER_VERSION=$(cat FLUTTER_VERSION)
echo "FLUTTER_VERSION=${FLUTTER_VERSION}" >> $GITHUB_ENV
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'any'
- name: ✅ Enable platforms
run: flutter config --enable-windows-desktop
- name: 📦 Get dependencies
run: |
flutter clean
flutter pub get
flutter doctor -v
- name: 🏭 Build
shell: pwsh
run: |
flutter build windows -v --release
- name: Build setup
shell: pwsh
run: |
Get-Content pubspec.yaml | Select-String -Pattern 'version:\s(.+)\+' | % {Set-Item -Path Env:BUTTERFLY_VERSION -Value "$($_.matches.groups[1])"}
& 'C:/Program Files (x86)/Inno Setup 6/ISCC.exe' /DMyAppVersion=$Env:BUTTERFLY_VERSION ButterflySetup.iss
# flutter pub run msix:create
- name: Archive
uses: actions/upload-artifact@v3
with:
name: windows-build
path: |
app/build/windows/runner/Release/**
- name: Archive
uses: actions/upload-artifact@v3
with:
name: windows-setup
path: |
app/build/windows/linwood-butterfly-windows-setup.exe
build-linux:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: app
steps:
- name: ⬆️ Checkout
uses: actions/checkout@v3
- name: Get dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3-pip \
python3-setuptools \
desktop-file-utils \
libgdk-pixbuf2.0-dev \
fakeroot \
strace \
fuse \
libgtk-3-dev \
libx11-dev \
pkg-config \
cmake \
ninja-build \
libblkid-dev \
liblzma-dev \
clang \
dpkg-dev \
patchelf \
alien \
libsecret-1-dev \
libjsoncpp-dev
- name: Get flutter version
run: |
FLUTTER_VERSION=$(cat FLUTTER_VERSION)
echo "FLUTTER_VERSION=${FLUTTER_VERSION}" >> $GITHUB_ENV
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'any'
- name: ✅ Enable platforms
run: flutter config --enable-linux-desktop
- name: 📦 Get dependencies
run: |
flutter clean
flutter pub get
flutter doctor -v
- name: 🏭 Build
run: |
flutter build linux -v --release
- name: Build .deb executable
run: |
cp -fr build/linux/x64/release/bundle linux/debian/usr/bin
dpkg-deb --build --root-owner-group linux/debian
cp linux/*.deb linwood-butterfly-linux.deb
#- name: Build .rpm executable
# run: |
# cd app
# alien -r linwood-butterfly-linux.deb
# mv linwood-butterfly*.rpm linwood-butterfly-linux.rpm
- name: Build .AppImage executable
run: |
wget -O appimage-builder-x86_64.AppImage https://github.com/AppImageCrafters/appimage-builder/releases/download/v1.0.0-beta.1/appimage-builder-1.0.0-677acbd-x86_64.AppImage
chmod +x appimage-builder-x86_64.AppImage
sudo mv appimage-builder-x86_64.AppImage /usr/local/bin/appimage-builder
appimage-builder --recipe AppImageBuilder.yml --skip-test
- name: Copy nessessary files
run: |
cp images/logo.svg build/linux/x64/release/bundle/dev.linwood.butterfly.svg
mkdir -p build/linux/x64/release/bundle/usr/share
cp -r linux/debian/usr/share build/linux/x64/release/bundle/usr
- name: Rename AppImage
run: |
mv ./*.AppImage* linwood-butterfly-linux.AppImage
- name: Archive
uses: actions/upload-artifact@v3
with:
name: linux-build
path: |
app/build/linux/x64/release/bundle/**
- name: Archive .deb
uses: actions/upload-artifact@v3
with:
name: linux-deb
path: |
app/linwood-butterfly-linux.deb
#- name: Archive .rpm
# uses: actions/upload-artifact@v3
# with:
# name: linux-rpm
# path: |
# app/linwood-butterfly-linux.rpm
- name: Archive .AppImage
uses: actions/upload-artifact@v3
with:
name: linux-appimage
path: |
app/linwood-butterfly-linux.AppImage
build-flatpak:
name: Build flatpak
runs-on: ubuntu-20.04
defaults:
run:
working-directory: app
steps:
- name: ⬆️ Checkout
uses: actions/checkout@v3
- name: Get dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3-pip \
python3-setuptools \
desktop-file-utils \
libgdk-pixbuf2.0-dev \
fakeroot \
strace \
fuse \
libgtk-3-dev \
libx11-dev \
pkg-config \
cmake \
ninja-build \
libblkid-dev \
liblzma-dev \
clang \
dpkg-dev \
patchelf \
alien \
libsecret-1-dev \
libjsoncpp-dev
- name: Get flutter version
run: |
FLUTTER_VERSION=$(cat FLUTTER_VERSION)
echo "FLUTTER_VERSION=${FLUTTER_VERSION}" >> $GITHUB_ENV
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'any'
- name: ✅ Enable platforms
run: flutter config --enable-linux-desktop
- name: 📦 Get dependencies
run: |
flutter clean
flutter pub get
flutter doctor -v
- name: 🏭 Build
run: |
flutter build linux -v --release
- name: Copy nessessary files
run: |
cp images/logo.svg build/linux/x64/release/bundle/dev.linwood.butterfly.svg
mkdir -p build/linux/x64/release/bundle/usr/share
cp -r linux/debian/usr/share build/linux/x64/release/bundle/usr
- name: Compress Flutter build
run: tar -C build/linux/x64/release/bundle -czf linwood-butterfly-linux-portable.tar.gz .
# - name: Install flatpak
# run: |
# sudo apt-get update
# sudo apt-get install -y flatpak
# - name: Install dependencies
# run: |
# flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo --user
# flatpak install flathub org.flatpak.Builder --user -y --arch=x86_64
# - name: Build .flatpak
# timeout-minutes: 15
# run: |
# flatpak run org.flatpak.Builder -v --force-clean --sandbox --delete-build-dirs --user --install-deps-from=flathub --arch=x86_64 flatpak_app flatpak.json --bundle-sources
# flatpak build-export export flatpak_app -v
# flatpak build-bundle export linwood-butterfly-linux.flatpak dev.linwood.butterfly -v
# - name: Upload .flatpak artifact to workflow
# uses: actions/upload-artifact@v3
# with:
# name: linux-flatpak
# path: app/linwood-butterfly-linux.flatpak
- name: Archive old portable
uses: actions/upload-artifact@v3
with:
name: linux-alternative-portable
path: app/build/linux/x64/release/bundle
#build-macos:
# runs-on: macos-latest
# defaults:
# run:
# working-directory: app
# steps:
# - name: ⬆️ Checkout
# uses: actions/checkout@v3
# - name: Get flutter version
# run: |
# FLUTTER_VERSION=$(cat FLUTTER_VERSION)
# echo "FLUTTER_VERSION=${FLUTTER_VERSION}" >> $GITHUB_ENV
# - uses: subosito/flutter-action@v2
# with:
# flutter-version: ${{ env.FLUTTER_VERSION }}
# channel: 'any'
# - name: ✅ Enable platforms
# run: flutter config --enable-macos-desktop
# - name: 📦 Get dependencies
# run: |
# flutter clean
# flutter pub get
# flutter doctor -v
# - name: 🏭 Build
# run: |
# flutter build macos -v
# - name: Archive
# uses: actions/upload-artifact@v3
# with:
# name: macos-build
# path: |
# app/build/macos/Build/Products/Release/butterfly.app
deploy:
runs-on: ubuntu-22.04
if: github.event_name == 'push'
outputs:
version: ${{ steps.setup.outputs.BUTTERFLY_VERSION }}
build_number: ${{ steps.setup.outputs.BUTTERFLY_BUILD_NUMBER }}
needs:
- build-apk
- build-windows
- build-linux
- build-flatpak
#- build-macos
steps:
- name: ⬆️ Checkout
uses: actions/checkout@v3
env:
CI_PAT: ${{ secrets.CI_PAT }}
with:
token: ${{ env.CI_PAT }}
- name: Setup git
id: setup
run: |
BUTTERFLY_VERSION_REGEX="version:\s(.+)\+(.+)"
[[ $(grep -E "${BUTTERFLY_VERSION_REGEX}" app/pubspec.yaml) =~ ${BUTTERFLY_VERSION_REGEX} ]]
BUTTERFLY_VERSION="${BASH_REMATCH[1]}"
echo "BUTTERFLY_VERSION=${BUTTERFLY_VERSION}" >> $GITHUB_ENV
echo "BUTTERFLY_VERSION=${BUTTERFLY_VERSION}" >> $GITHUB_OUTPUT
BUTTERFLY_BUILD_NUMBER="${BASH_REMATCH[2]}"
echo "BUTTERFLY_BUILD_NUMBER=${BUTTERFLY_BUILD_NUMBER}" >> $GITHUB_ENV
echo "BUTTERFLY_BUILD_NUMBER=${BUTTERFLY_BUILD_NUMBER}" >> $GITHUB_OUTPUT
git config --global user.email "[email protected]"
git config --global user.name "Linwood CI"
- uses: actions/download-artifact@v3
with:
name: apk-build
- uses: actions/download-artifact@v3
with:
name: windows-build
path: windows-build/
- uses: actions/download-artifact@v3
with:
name: linux-build
path: linux-build/
- uses: actions/download-artifact@v3
with:
name: linux-deb
#- uses: actions/download-artifact@v3
# with:
# name: linux-rpm
- uses: actions/download-artifact@v3
with:
name: linux-appimage
#- uses: actions/download-artifact@v3
# with:
# name: linux-flatpak
- uses: actions/download-artifact@v3
with:
name: linux-alternative-portable
path: linux-alternative-portable/
- uses: actions/download-artifact@v3
with:
name: windows-setup
#- uses: actions/download-artifact@v3
# with:
# name: macos-build
# path: macos-build/
- name: 📦 Zip artifacts
run: |
zip -r linwood-butterfly-windows.zip windows-build/*
tar -C linux-build -czf linwood-butterfly-linux.tar.gz .
tar -C linux-alternative-portable -czf linwood-butterfly-linux-alternative.tar.gz .
# tar -C macos-build -czf linwood-butterfly-macos.tar.gz .
- name: Configure git
if: ${{ github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' }}
run: |
git --version
git config --global user.email "[email protected]"
git config --global user.name "Actions"
git pull --tags
- name: 🚀 Deploy stable
if: ${{ github.ref == 'refs/tags/stable' }}
uses: softprops/action-gh-release@v1
continue-on-error: true
with:
prerelease: true
tag_name: stable
files: |
linwood-butterfly-windows-setup.exe
linwood-butterfly-windows.zip
linwood-butterfly-android.apk
linwood-butterfly-linux.tar.gz
linwood-butterfly-linux-alternative.tar.gz
linwood-butterfly-linux.deb
linwood-butterfly-linux.AppImage
# linwood-butterfly-macos.tar.gz
# linwood-butterfly-linux.flatpak
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 🚀 Deploy nightly
if: ${{ github.ref == 'refs/tags/nightly' }}
uses: softprops/action-gh-release@v1
continue-on-error: true
with:
prerelease: true
tag_name: nightly
files: |
linwood-butterfly-windows-setup.exe
linwood-butterfly-windows.zip
linwood-butterfly-android.apk
linwood-butterfly-linux.tar.gz
linwood-butterfly-linux-alternative.tar.gz
linwood-butterfly-linux.deb
linwood-butterfly-linux.AppImage
# linwood-butterfly-macos.tar.gz
# linwood-butterfly-linux.flatpak
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release
uses: softprops/action-gh-release@v1
continue-on-error: true
if: startsWith(github.ref, 'refs/tags/v')
with:
files: |
linwood-butterfly-windows-setup.exe
linwood-butterfly-windows.zip
linwood-butterfly-android.apk
linwood-butterfly-linux.tar.gz
linwood-butterfly-linux-alternative.tar.gz
linwood-butterfly-linux.deb
linwood-butterfly-linux.AppImage
# linwood-butterfly-macos.tar.gz
# linwood-butterfly-linux.flatpak
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy-to-play-store:
runs-on: ubuntu-22.04
if: ${{ startsWith(github.ref, 'refs/tags/') }}
defaults:
run:
working-directory: app
env:
PLAY_STORE_CREDENTIALS: ${{ secrets.PLAY_STORE_CREDENTIALS }}
steps:
- name: ⬆️ Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.CI_PAT }}
- name: Setup git
run: |
git config --global user.email "[email protected]"
git config --global user.name "Linwood CI"
- name: Import files
env:
KEY_JKS: ${{ secrets.KEY_JKS }}
KEY_PROPERTIES: ${{ secrets.KEY_PROPERTIES }}
PLAY_STORE_CREDENTIALS: ${{ secrets.PLAY_STORE_CREDENTIALS }}
if: ${{ env.PLAY_STORE_CREDENTIALS != '' }}
run: |
cd android
if [[ -n "$KEY_PROPERTIES" ]] ; then echo "$KEY_PROPERTIES" | base64 --decode > key.properties ; fi
if [[ -n "$KEY_JKS" ]] ; then echo "$KEY_JKS" | base64 --decode > key.jks ; fi
echo "$PLAY_STORE_CREDENTIALS" | base64 --decode > play-store-credentials.json
- name: 🔧 Setup java
uses: actions/setup-java@v3
with:
java-version: "11"
distribution: "adopt"
- name: Get flutter version
run: |
FLUTTER_VERSION=$(cat FLUTTER_VERSION)
echo "FLUTTER_VERSION=${FLUTTER_VERSION}" >> $GITHUB_ENV
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'any'
- name: 📦 Get dependencies
run: |
flutter pub get
- name: Setup Fastlane
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1.3"
bundler-cache: true
working-directory: app/android
- name: 🚀 Deploy to Play Store
if: ${{ github.ref == 'refs/tags/stable' && env.PLAY_STORE_CREDENTIALS != '' }}
env:
PLAY_STORE_CREDENTIALS: ${{ secrets.PLAY_STORE_CREDENTIALS }}
run: bundle exec fastlane deploy
working-directory: app/android
- name: 🚀 Deploy to Play Store
if: ${{ github.ref == 'refs/tags/nightly' && env.PLAY_STORE_CREDENTIALS != '' }}
env:
PLAY_STORE_CREDENTIALS: ${{ secrets.PLAY_STORE_CREDENTIALS }}
run: bundle exec fastlane beta
working-directory: app/android
publish-winget:
needs: [deploy]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.CI_PAT }}
- if: ${{ github.ref == 'refs/tags/stable' }}
uses: vedantmgoyal2009/winget-releaser@v1
with:
identifier: LinwoodCloud.Butterfly
version: ${{ needs.deploy.outputs.version }}
release-tag: v${{ needs.deploy.outputs.version }}
token: ${{ secrets.CI_PAT }}
- if: ${{ github.ref == 'refs/tags/nightly' }}
uses: vedantmgoyal2009/winget-releaser@v1
with:
identifier: LinwoodCloud.Butterfly.Nightly
version: ${{ needs.deploy.outputs.version }}
release-tag: v${{ needs.deploy.outputs.version }}
token: ${{ secrets.CI_PAT }}