-
-
Notifications
You must be signed in to change notification settings - Fork 21
414 lines (344 loc) · 13.7 KB
/
Copy pathmain.yml
File metadata and controls
414 lines (344 loc) · 13.7 KB
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
name: Build and Release
on:
push:
branches: [main]
paths-ignore:
- "pubspec.yaml"
workflow_dispatch:
env:
PUB_SUMMARY_ONLY: true
KOTLIN_VERSION: "2.1.0"
jobs:
quality-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup Flutter from submodule
run: |
git submodule update --init --recursive flutter
chmod +x flutter/bin/*
echo "$PWD/flutter/bin" >> $GITHUB_PATH
flutter/bin/flutter --version
flutter/bin/flutter config --no-analytics
- name: Get dependencies
run: flutter pub get
- name: Verify formatting
run: dart format --set-exit-if-changed lib test
- name: Analyze code
run: dart analyze --no-fatal-warnings lib
- name: Run tests
run: flutter test
version-bump:
needs: quality-checks
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.bump.outputs.version }}
build_number: ${{ steps.bump.outputs.build_number }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: false
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Bump versions and generate changelog
id: bump
run: |
CURRENT_VERSION=$(grep '^version:' pubspec.yaml | sed 's/version: //' | sed 's/+.*//')
CURRENT_BUILD=$(grep '^version:' pubspec.yaml | sed 's/.*+//')
CURRENT_MSIX=$(grep 'msix_version:' pubspec.yaml | sed 's/.*msix_version: *//')
IFS='.' read -ra V <<< "$CURRENT_VERSION"
NEW_VERSION="${V[0]}.${V[1]}.$((${V[2]} + 1))"
NEW_BUILD=$((CURRENT_BUILD + 1))
CHANGELOG_NUMBER=$((NEW_BUILD * 10 + 3))
IFS='.' read -ra M <<< "$CURRENT_MSIX"
NEW_MSIX="${M[0]}.${M[1]}.$((${M[2]} + 1)).${M[3]}"
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "build_number=$NEW_BUILD" >> $GITHUB_OUTPUT
sed -i "s/^version: .*/version: $NEW_VERSION+$NEW_BUILD/" pubspec.yaml
sed -i "s/msix_version: .*/msix_version: $NEW_MSIX/" pubspec.yaml
CHANGELOG_FILE="fastlane/metadata/android/en-US/changelogs/$CHANGELOG_NUMBER.txt"
mkdir -p "$(dirname "$CHANGELOG_FILE")"
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
git --no-pager log --pretty=format:'%s' "$LAST_TAG"..HEAD
else
git --no-pager log --pretty=format:'%s'
fi | sort -u \
| grep -v "^Merge " \
| grep -v "^Release " \
| grep -v "^Bump " \
| grep -v "\[skip ci\]" \
| head -10 \
| sed 's/^/• /' > "$CHANGELOG_FILE"
[ -s "$CHANGELOG_FILE" ] || echo "• Bug fixes and improvements" > "$CHANGELOG_FILE"
mkdir -p fastlane/metadata/en-AU
cp "$CHANGELOG_FILE" fastlane/metadata/en-AU/release_notes.txt
mkdir -p assets/changelogs
cp "$CHANGELOG_FILE" "assets/changelogs/$(date +%s).txt"
- name: Commit and push version bump
run: |
git add pubspec.yaml fastlane/metadata assets/changelogs
git commit -m "Release ${{ steps.bump.outputs.version }} [skip ci]"
git push origin main
- name: Create and push tag
run: |
git tag "${{ steps.bump.outputs.version }}"
git push origin "${{ steps.bump.outputs.version }}"
build-android:
needs: version-bump
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "17"
- name: Create brandon user directory structure (match F-Droid)
run: |
sudo mkdir -p /home/brandon
sudo chown $USER -R /home/brandon
- name: Move project to F-Droid location
run: |
cd ..
mv ${{ github.event.repository.name }} /home/brandon/fitbook
- name: Setup Flutter from submodule and get dependencies
working-directory: /home/brandon/fitbook
run: |
git submodule update --init --recursive flutter
echo "/home/brandon/fitbook/flutter/bin" >> $GITHUB_PATH
export PUB_CACHE=$(pwd)/.pub-cache
echo "PUB_CACHE=$(pwd)/.pub-cache" >> $GITHUB_ENV
flutter/bin/flutter config --no-analytics
flutter/bin/flutter pub get
- name: Strip non-deterministic build IDs from jni native library
working-directory: /home/brandon/fitbook
run: |
sed -i -e 's/-Wl,/-Wl,--build-id=none,/' \
.pub-cache/hosted/pub.dev/jni-*/src/CMakeLists.txt
- name: Decode Android keystore
working-directory: /home/brandon/fitbook
run: echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 --decode > android/app/keystore.jks
- name: Build android
working-directory: /home/brandon/fitbook
run: |
echo "storePassword=${{ secrets.ANDROID_STORE_PASSWORD }}" > android/key.properties
echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >> android/key.properties
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" >> android/key.properties
echo "storeFile=keystore.jks" >> android/key.properties
# Use --split-per-abi WITH --target-platform to match F-Droid exactly.
# Without --split-per-abi: produces a universal APK with all ABI native
# libs and versionCode override = base*10+3 (wrong for x86_64 which needs +1).
# Without --target-platform: NativeAssetsManifest.json lists all 3 archs.
flutter build apk --release --split-per-abi --target-platform android-x64
flutter build apk --release --split-per-abi --target-platform android-arm64
flutter build apk --release --split-per-abi --target-platform android-arm
flutter build apk --release
mv build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/fitbook.apk
flutter build appbundle
mkdir -p "${GITHUB_WORKSPACE}/build"
mv build/* "${GITHUB_WORKSPACE}/build"
- name: Upload Android artifacts
uses: actions/upload-artifact@v4
with:
name: android-builds
path: |
build/app/outputs/flutter-apk/app-*-release.apk
build/app/outputs/flutter-apk/fitbook.apk
build/app/outputs/bundle/release/app-release.aab
build-linux:
needs: version-bump
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Flutter from submodule
run: |
git submodule update --init --recursive flutter
chmod +x flutter/bin/*
echo "${{ github.workspace }}/flutter/bin" >> $GITHUB_PATH
flutter/bin/flutter config --no-analytics
- name: Get Flutter dependencies
run: flutter pub get
- name: Install Linux dependencies
run: |
sudo apt-get update
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 build linux
- name: Create Linux zip
run: |
cd build/linux/x64/release/bundle
zip -r fitbook-linux.zip .
- name: Upload Linux artifacts
uses: actions/upload-artifact@v4
with:
name: linux-builds
path: build/linux/x64/release/bundle/fitbook-linux.zip
build-windows:
needs: version-bump
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Flutter from submodule
run: |
git submodule update --init --recursive flutter
chmod +x flutter/bin/*
echo "${{ github.workspace }}\flutter\bin" >> $env:GITHUB_PATH
flutter\bin\flutter config --no-analytics
- name: Get Flutter dependencies
run: flutter pub get
- name: Build Windows
run: flutter build windows
- name: Create Windows zip
run: Compress-Archive -Path ./build/windows/x64/runner/Release/* -DestinationPath ./fitbook-windows.zip
- name: Upload Windows artifacts
uses: actions/upload-artifact@v4
with:
name: windows-builds
path: fitbook-windows.zip
build-and-deploy-web:
needs: version-bump
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
contents: write
pages: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Flutter from submodule
run: |
git submodule update --init --recursive flutter
chmod +x flutter/bin/*
echo "${{ github.workspace }}/flutter/bin" >> $GITHUB_PATH
flutter/bin/flutter config --no-analytics
- name: Get Flutter dependencies
run: flutter pub get
- name: Enable web support
run: flutter config --enable-web
- name: Build Flutter web
run: flutter build web --release --base-href /${{ github.event.repository.name }}/
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload to GitHub Pages
uses: actions/upload-pages-artifact@v3
with:
path: ./build/web
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
create-github-release:
needs: [version-bump, build-android, build-linux, build-windows]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.version-bump.outputs.version }}
name: ${{ needs.version-bump.outputs.version }}
body_path: fastlane/metadata/en-AU/release_notes.txt
files: |
android-builds/flutter-apk/app-*-release.apk
android-builds/flutter-apk/fitbook.apk
android-builds/bundle/release/app-release.aab
linux-builds/fitbook-linux.zip
windows-builds/fitbook-windows.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy-windows-store:
needs: [version-bump, build-windows]
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Flutter from submodule
run: |
git submodule update --init --recursive flutter
echo "${{ github.workspace }}\flutter\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
flutter\bin\flutter config --no-analytics
- name: Get Flutter dependencies
run: flutter pub get
- name: Build MSIX
run: flutter pub run msix:create
- name: Setup .NET 9.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: "9.0.x"
- name: Setup Microsoft Store CLI
uses: microsoft/setup-msstore-cli@v1
- name: Configure Microsoft Store CLI
run: msstore reconfigure --tenantId ${{ secrets.AZURE_TENANT_ID }} --clientId ${{ secrets.AZURE_CLIENT_ID }} --clientSecret ${{ secrets.AZURE_CLIENT_SECRET }} --sellerId ${{ secrets.MSSTORE_SELLER_ID }}
- name: Publish to Microsoft Store
run: msstore publish --inputDirectory build/windows/x64/runner/Release --appId ${{ secrets.PRODUCT_ID }} --packageRolloutPercentage 100 || true
virustotal:
needs: [create-github-release, version-bump]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download Android artifacts
uses: actions/download-artifact@v4
with:
name: android-builds
path: android-builds
- name: VirusTotal Scan
id: vt
uses: crazy-max/ghaction-virustotal@v4
with:
vt_api_key: ${{ secrets.VT_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
files: |
android-builds/flutter-apk/app-arm64-v8a-release.apk
android-builds/flutter-apk/app-armeabi-v7a-release.apk
android-builds/flutter-apk/app-x86_64-release.apk
- name: Append VirusTotal links to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.version-bump.outputs.version }}
ANALYSIS: ${{ steps.vt.outputs.analysis }}
run: |
VT_SECTION=$'\n\n<details>\n<summary>VirusTotal Analysis</summary>\n\n'
IFS=',' read -ra ENTRIES <<< "$ANALYSIS"
for entry in "${ENTRIES[@]}"; do
filename=$(basename "${entry%%=*}")
url="${entry#*=}"
VT_SECTION+="- [${filename}](${url})"$'\n'
done
VT_SECTION+=$'\n</details>'
CURRENT_BODY=$(gh release view "$VERSION" --json body -q .body)
gh release edit "$VERSION" --notes "${CURRENT_BODY}${VT_SECTION}"