-
-
Notifications
You must be signed in to change notification settings - Fork 12
376 lines (332 loc) · 15.4 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
name: Project Release Artifacts
on:
push:
tags:
- 'v*'
jobs:
release:
name: Create Release Page
runs-on: ubuntu-latest
outputs:
version: ${{ steps.tag.outputs.name }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
build_number: ${{ steps.build_number.outputs.build_number }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- run: flutter pub get
- name: Get Tag Name
id: tag
run: echo "name=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Prepare Release Notes
run: |
dart run grinder release-notes --tag=v${{ steps.tag.outputs.name }} --output=release_notes.log
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
while IFS= read -r line; do
echo "$line" >> $GITHUB_ENV
done < "release_notes.log"
echo "EOF" >> $GITHUB_ENV
rm release_notes.log
- name: Set Build Number
id: build_number
run: echo "build_number=$(git rev-list --count HEAD)" >> $GITHUB_OUTPUT
- name: Create Release Page
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.tag.outputs.name }}
release_name: Release ${{ steps.tag.outputs.name }}
body: ${{ env.RELEASE_NOTES }}
draft: true
prerelease: false
build:
name: Create ${{ matrix.target }} build
runs-on: ${{ matrix.os }}
needs: release
strategy:
fail-fast: false
matrix:
target: [macOS, iOS, Windows, Linux, LinuxSnap, Android, Web]
include:
- os: macos-latest
target: macOS
build_path: build/macos/Build/Products/Release
asset_extension: .zip
asset_content_type: application/zip
- os: macos-latest
target: iOS
build_path: build/ios/ipa
asset_extension: .ipa
asset_content_type: application/zip
- os: windows-latest
target: Windows
build_path: build/windows/x64/runner/Release
asset_extension: .zip
asset_content_type: application/zip
- os: ubuntu-latest
target: Linux
build_path: build/linux/x64/release/bundle
asset_extension: .tar.gz
asset_content_type: application/gzip
- os: ubuntu-latest
target: LinuxSnap
build_path: ./
asset_extension: .snap
asset_content_type: application/gzip
- os: ubuntu-latest
target: Android
build_path: build/app/outputs/bundle/release/
asset_extension: .aab
asset_content_type: application/zip
- os: ubuntu-latest
target: Web
build_path: build/web/
asset_extension: .tar.gz
asset_content_type: application/gzip
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
cache: true
- run: flutter pub get
- name: Patch PubSpec
run: dart run grinder pubspec-update --build-name=${{ needs.release.outputs.version }} --build-number=${{ needs.release.outputs.build_number }}
# Web
- name: Build Web Package
if: matrix.target == 'Web'
run: flutter build -v web --release --no-tree-shake-icons --base-href="/app/finance/"
- name: Compress Web Package
if: matrix.target == 'Web'
run: tar czf $GITHUB_WORKSPACE/fingrom_${{ matrix.target }}${{ matrix.asset_extension }} *
working-directory: ${{ matrix.build_path }}
# Windows
- name: Run Windows Build
if: matrix.target == 'Windows'
run: |
flutter config --enable-windows-desktop
flutter build -v windows --build-name=${{ needs.release.outputs.version }} --build-number=${{ needs.release.outputs.build_number }} --release --obfuscate --split-debug-info=build/windows/symbols
- name: Copy Additional DLLs
if: matrix.target == 'Windows'
run: |
Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\msvcp140.dll') .
Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\vcruntime140.dll') .
Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\vcruntime140_1.dll') .
working-directory: ${{ matrix.build_path }}
- name: Generate Windows MSIX-package
if: matrix.target == 'Windows'
run: dart run msix:create --version ${{ needs.release.outputs.version }}.0 --output-path ${{ matrix.build_path }} --output-name Fingrom --build-windows false
- name: Compress Windows Package
if: matrix.target == 'Windows'
run: compress-archive -Path * -DestinationPath ${env:GITHUB_WORKSPACE}/fingrom_${{ matrix.target }}${{ matrix.asset_extension }}
working-directory: ${{ matrix.build_path }}
- name: Setup MS Store CLI
if: matrix.target == 'Windows'
uses: microsoft/setup-msstore-cli@ec39acd1144351ab7a9d8d25e12bf6fd1ba03150
- name: Publish MSIX to the Microsoft Store
if: matrix.target == 'Windows'
run: |
msstore reconfigure --tenantId ${{ secrets.WINDOWS_TENANT_ID }} --clientId ${{ secrets.WINDOWS_CLIENT_ID }} --clientSecret ${{ secrets.WINDOWS_SECRET }} --sellerId ${{ secrets.WINDOWS_SELLER_ID }}
msstore publish -i ${{ matrix.build_path }} || echo "Publishing failed since replaced build in review state."
# Linux
- name: Run Linux Build
if: matrix.target == 'Linux'
run: |
sudo apt-get install -y libgtk-3-dev ninja-build
flutter config --enable-linux-desktop
flutter build -v linux --build-name=${{ needs.release.outputs.version }} --build-number=${{ needs.release.outputs.build_number }} --release
- name: Compress Linux Package
if: matrix.target == 'Linux'
run: |
cp $GITHUB_WORKSPACE/com.tercad.fingrom.desktop ./
cp $GITHUB_WORKSPACE/com.tercad.fingrom.svg ./
tar czf $GITHUB_WORKSPACE/fingrom_${{ matrix.target }}${{ matrix.asset_extension }} *
working-directory: ${{ matrix.build_path }}
# Linux Snap
- name: Install Snapcraft
if: matrix.target == 'LinuxSnap'
uses: canonical/[email protected]
- name: Build Snap
if: matrix.target == 'LinuxSnap'
run: |
sudo snap install snapcraft --classic
snapcraft --verbose
cp fingrom_${{ needs.release.outputs.version }}+${{ needs.release.outputs.build_number }}_amd64.snap fingrom_${{ matrix.target }}.snap
- name: Publish Snap
if: matrix.target == 'LinuxSnap'
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_CREDENTIALS }}
run: |
sudo --preserve-env=SNAPCRAFT_STORE_CREDENTIALS snapcraft upload fingrom_${{ matrix.target }}.snap --release=latest/stable
# Android
- name: Apply Android Keychain
if: matrix.target == 'Android'
env:
ANDROID_JKS: ${{ secrets.ANDROID_JKS }}
ANDROID_KEY: ${{ secrets.ANDROID_KEY }}
run: |
mkdir -p ~/private_keys
echo -n "$ANDROID_JKS" | base64 -d > $GITHUB_WORKSPACE/android/app/key.jks
echo -n "$ANDROID_KEY" | base64 -d > $GITHUB_WORKSPACE/android/key.properties
- name: Run Android Build
if: matrix.target == 'Android'
run: |
flutter build appbundle --build-name=${{ needs.release.outputs.version }} --build-number=${{ needs.release.outputs.build_number }} --release --no-tree-shake-icons --obfuscate --split-debug-info=build/app/symbols
mv ${{ matrix.build_path }}/app-release.aab $GITHUB_WORKSPACE/fingrom_${{ matrix.target }}.aab
# iOS
- name: Import Distribution Certificate
if: matrix.target == 'iOS'
uses: apple-actions/import-codesign-certs@v2
with:
keychain: signing_distr
p12-file-base64: ${{ secrets.APPLE_P12 }}
p12-password: ${{ secrets.APPLE_P12_KEY }}
# - name: Import Development Certificate
# if: matrix.target == 'iOS'
# uses: apple-actions/import-codesign-certs@v2
# with:
# keychain: signing_dev
# p12-file-base64: ${{ secrets.APPLE_DEV_P12 }}
# p12-password: ${{ secrets.APPLE_DEV_P12_KEY }}
- name: Install the Provisioning Profile
if: matrix.target == 'iOS'
env:
PROVISIONING_CERTIFICATE_BASE64: ${{ secrets.APPLE_IOS_PROFILE }}
run: |
PP_PATH=$RUNNER_TEMP/Fingrom_iOS.mobileprovision
echo -n "$PROVISIONING_CERTIFICATE_BASE64" | base64 --decode --output $PP_PATH
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- name: Store API key
if: matrix.target == 'iOS' || matrix.target == 'macOS'
env:
API_CERTIFICATE_BASE64: ${{ secrets.APPLE_API_P8 }}
run: |
mkdir -p ~/private_keys
echo -n "$API_CERTIFICATE_BASE64" | base64 --decode --output ~/private_keys/AuthKey_${{ secrets.APPLE_API_KEY }}.p8
- name: Run iOS Build
if: matrix.target == 'iOS'
run: |
flutter build ipa --build-name=${{ needs.release.outputs.version }} --build-number=${{ needs.release.outputs.build_number }} --release --obfuscate --split-debug-info=build/ios/symbols --no-tree-shake-icons --export-options-plist ./ios/ExportOptions.plist
mv ${{ matrix.build_path }}/fingrom.ipa fingrom_${{ matrix.target }}.ipa
- name: Upload iOS Package to Apple Store
if: matrix.target == 'iOS'
run: |
xcrun altool --validate-app --type ios -f fingrom_${{ matrix.target }}.ipa --apiKey ${{ secrets.APPLE_API_KEY }} --apiIssuer ${{ secrets.APPLE_API_ISSUE }}
xcrun altool --upload-app --type ios -f fingrom_${{ matrix.target }}.ipa --apiKey ${{ secrets.APPLE_API_KEY }} --apiIssuer ${{ secrets.APPLE_API_ISSUE }}
# macOS
- name: Run macOS Build
if: matrix.target == 'macOS'
run: |
flutter config --enable-macos-desktop
flutter build -v macos --build-name=${{ needs.release.outputs.version }} --build-number=${{ needs.release.outputs.build_number }} --release --obfuscate --split-debug-info=build/macos/symbols --no-tree-shake-icons
- name: Add the Provisioning Profile
if: matrix.target == 'macOS'
env:
PROVISIONING_MAC_BASE64: ${{ secrets.APPLE_MAC_PROFILE }}
run: |
PP_PATH=$RUNNER_TEMP/Fingrom_macOS.provisionprofile
echo -n "$PROVISIONING_MAC_BASE64" | base64 --decode --output $PP_PATH
cp $PP_PATH ${{ matrix.build_path }}/Fingrom.app/Contents/embedded.provisionprofile
- name: Compress macOS Package
if: matrix.target == 'macOS'
run: ditto -c -k --sequesterRsrc --keepParent Fingrom.app $GITHUB_WORKSPACE/fingrom_${{ matrix.target }}${{ matrix.asset_extension }}
working-directory: ${{ matrix.build_path }}
- name: Import macOS Distribution Certificate
if: matrix.target == 'macOS'
uses: apple-actions/import-codesign-certs@v2
with:
keychain: signing_distr
p12-file-base64: ${{ secrets.APPLE_MAC_P12 }}
p12-password: ${{ secrets.APPLE_P12_KEY }}
- name: Sign macOS Package
if: matrix.target == 'macOS'
run: |
codesign --deep --force -s "8PVKPQ758L" --entitlements $GITHUB_WORKSPACE/macos/Runner/Release.entitlements "Fingrom.app"
working-directory: ${{ matrix.build_path }}
- name: Import macOS Installer Certificate
if: matrix.target == 'macOS'
uses: apple-actions/import-codesign-certs@v2
with:
keychain: signing_installer
p12-file-base64: ${{ secrets.APPLE_MAC_INSTALLER }}
p12-password: ${{ secrets.APPLE_P12_KEY }}
- name: Create macOS Package for Apple Store
if: matrix.target == 'macOS'
run: |
xcrun productbuild --component Fingrom.app /Applications/ unsigned.pkg
xcrun productsign --sign "8PVKPQ758L" unsigned.pkg Fingrom.pkg
working-directory: ${{ matrix.build_path }}
- name: Upload macOS Package to Apple Store
if: matrix.target == 'macOS'
run: |
xcrun altool --validate-app --type macos -f Fingrom.pkg --apiKey ${{ secrets.APPLE_API_KEY }} --apiIssuer ${{ secrets.APPLE_API_ISSUE }}
xcrun altool --upload-app --type macos -f Fingrom.pkg --apiKey ${{ secrets.APPLE_API_KEY }} --apiIssuer ${{ secrets.APPLE_API_ISSUE }}
working-directory: ${{ matrix.build_path }}
#
- name: Upload ${{ matrix.target }} Artifact
id: upload_release_asset
uses: actions/upload-release-asset@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./fingrom_${{ matrix.target }}${{ matrix.asset_extension }}
asset_name: fingrom_${{ matrix.target }}${{ matrix.asset_extension }}
asset_content_type: ${{ matrix.asset_content_type }}
# Linux Flatpak
build-flatpak:
name: Create Linux Flatpak build
needs:
- release
- build
runs-on: ubuntu-latest
container:
image: bilelmoussaoui/flatpak-github-actions:gnome-45
options: --privileged
steps:
- uses: actions/checkout@v3
- name: Patch Manifest
run: |
ASSET_URL="https://github.com/lyskouski/app-finance/releases/download/v${{ needs.release.outputs.version }}/fingrom_Linux.tar.gz"
curl -vLJO -H 'Accept: application/octet-stream' $ASSET_URL
sh patch.sh -i ${{ github.sha }} -v "${{ needs.release.outputs.version }}" -s $(sha256sum fingrom_Linux.tar.gz | gawk '{ print $1 }')
working-directory: linux-flatpak
- name: Build Linux Flatpak
uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v5
with:
bundle: fingrom_LinuxFlatpak.flatpak
manifest-path: linux-flatpak/com.tercad.fingrom.yml
- name: Store Configs for github.com/flathub
if: always()
uses: actions/upload-artifact@v3
with:
name: flatpak-configs
path: linux-flatpak
- name: Upload ${{ matrix.target }} Artifact
id: upload_release_asset
uses: actions/upload-release-asset@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./fingrom_LinuxFlatpak.flatpak
asset_name: fingrom_LinuxFlatpak.flatpak
asset_content_type: application/zip