-
Notifications
You must be signed in to change notification settings - Fork 0
285 lines (251 loc) · 11.1 KB
/
Copy pathbuild-multi-platform.yml
File metadata and controls
285 lines (251 loc) · 11.1 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
name: Build Multi Platform
permissions:
contents: write
on:
workflow_dispatch:
push:
branches: ["master"]
tags: ["v*"]
jobs:
build-desktop:
name: Build ${{ matrix.platform.name }} (${{ matrix.platform.arch }})
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- name: linux
arch: amd64
os: ubuntu-latest
build_command: flutter build linux --release --target-platform linux-x64
bundle_dir: x64
artifact_base: ailurus-linux
package_extension: AppImage
- name: linux
arch: arm64
os: ubuntu-24.04-arm
build_command: flutter build linux --release --target-platform linux-arm64
bundle_dir: arm64
artifact_base: ailurus-linux
package_extension: AppImage
- name: windows
arch: amd64
os: windows-latest
build_command: flutter build windows --release
artifact_base: ailurus-windows
package_extension: zip
- name: macos
arch: amd64
os: macos-15-intel
build_command: flutter build macos --release
artifact_base: ailurus-macos
package_extension: dmg
- name: macos
arch: arm64
os: macos-15
build_command: flutter build macos --release
artifact_base: ailurus-macos
package_extension: dmg
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Flutter (x64)
if: matrix.platform.arch != 'arm64'
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Setup Flutter (arm64)
if: matrix.platform.arch == 'arm64'
shell: bash
run: |
git clone https://github.com/flutter/flutter.git --depth 1 -b stable "$HOME/flutter"
echo "$HOME/flutter/bin" >> "$GITHUB_PATH"
export PATH="$HOME/flutter/bin:$PATH"
flutter --disable-analytics
flutter --version
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev
- name: Enable Linux desktop target
if: runner.os == 'Linux'
run: |
flutter config --enable-linux-desktop
- name: Enable Windows desktop target
if: runner.os == 'Windows'
shell: pwsh
run: |
flutter config --enable-windows-desktop
- name: Enable macOS desktop target
if: runner.os == 'macOS'
run: |
flutter config --enable-macos-desktop
- name: Get dependencies
run: flutter pub get
- name: Resolve package name
id: package_meta
shell: bash
run: |
APP_VERSION=$(grep '^version:' pubspec.yaml | sed 's/version:[[:space:]]*//' | cut -d+ -f1)
echo "name=${{ matrix.platform.artifact_base }}-${APP_VERSION}-${{ matrix.platform.arch }}.${{ matrix.platform.package_extension }}" >> "$GITHUB_OUTPUT"
- name: Resolve package checksum name
id: package_hash_meta
shell: bash
run: |
echo "name=${{ steps.package_meta.outputs.name }}.sha256" >> "$GITHUB_OUTPUT"
- name: Build desktop app
run: ${{ matrix.platform.build_command }}
- name: Package Linux AppImage
if: runner.os == 'Linux'
run: |
sudo apt-get install -y desktop-file-utils wget
rm -rf AppDir dist
mkdir -p AppDir/usr dist
cp build/linux/${{ matrix.platform.bundle_dir }}/release/bundle/ailurus AppDir/usr/
cp -r build/linux/${{ matrix.platform.bundle_dir }}/release/bundle/lib AppDir/usr/
cp -r build/linux/${{ matrix.platform.bundle_dir }}/release/bundle/data AppDir/usr/
cp assets/icons/app_icon_source.png AppDir/io.github.uniqueding.ailurus.png
cat > AppDir/AppRun <<'EOF'
#!/bin/sh
HERE="$(dirname "$(readlink -f "$0")")"
exec "$HERE/usr/ailurus" "$@"
EOF
chmod +x AppDir/AppRun
cat > AppDir/io.github.uniqueding.ailurus.desktop <<'EOF'
[Desktop Entry]
Type=Application
Name=Ailurus
Exec=ailurus
Icon=io.github.uniqueding.ailurus
Categories=Utility;
Terminal=false
EOF
desktop-file-validate AppDir/io.github.uniqueding.ailurus.desktop
if [ "${{ matrix.platform.arch }}" = "arm64" ]; then
APPIMAGE_TOOL_URL="https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-aarch64.AppImage"
APPIMAGE_ARCH="aarch64"
else
APPIMAGE_TOOL_URL="https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
APPIMAGE_ARCH="x86_64"
fi
wget -q "$APPIMAGE_TOOL_URL" -O appimagetool.AppImage
chmod +x appimagetool.AppImage
ARCH="$APPIMAGE_ARCH" ./appimagetool.AppImage --appimage-extract-and-run AppDir "dist/${{ steps.package_meta.outputs.name }}"
- name: Package Windows ZIP
if: runner.os == 'Windows'
shell: pwsh
run: |
if (Test-Path dist) { Remove-Item dist -Recurse -Force }
New-Item -ItemType Directory -Path dist | Out-Null
Compress-Archive -Path build/windows/x64/runner/Release/* -DestinationPath "dist/${{ steps.package_meta.outputs.name }}"
- name: Package macOS DMG
if: runner.os == 'macOS'
run: |
rm -rf dist
mkdir -p dist
hdiutil create -volname "Ailurus" -srcfolder "build/macos/Build/Products/Release/ailurus.app" -ov -format UDZO "dist/${{ steps.package_meta.outputs.name }}"
- name: Upload desktop artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform.name }}-${{ matrix.platform.arch }}-package
path: dist/${{ steps.package_meta.outputs.name }}
if-no-files-found: error
- name: Generate desktop checksum
shell: bash
run: |
sha256sum "dist/${{ steps.package_meta.outputs.name }}" > "dist/${{ steps.package_hash_meta.outputs.name }}"
- name: Upload desktop checksum artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform.name }}-${{ matrix.platform.arch }}-package-sha256
path: dist/${{ steps.package_hash_meta.outputs.name }}
if-no-files-found: error
- name: Upload desktop release asset
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1 || gh release create "${GITHUB_REF_NAME}" --generate-notes >/dev/null 2>&1 || true
gh release upload "${GITHUB_REF_NAME}" \
"dist/${{ steps.package_meta.outputs.name }}" \
"dist/${{ steps.package_hash_meta.outputs.name }}" \
--clobber
build-android-release:
name: Build signed android apk
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
environment: release
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Get dependencies
run: flutter pub get
- name: Resolve Android package names
id: android_meta
shell: bash
run: |
APP_VERSION=$(grep '^version:' pubspec.yaml | sed 's/version:[[:space:]]*//' | cut -d+ -f1)
echo "apk_arm64=ailurus-android-${APP_VERSION}-arm64.apk" >> "$GITHUB_OUTPUT"
echo "apk_arm64_sha=ailurus-android-${APP_VERSION}-arm64.apk.sha256" >> "$GITHUB_OUTPUT"
echo "apk_amd64=ailurus-android-${APP_VERSION}-amd64.apk" >> "$GITHUB_OUTPUT"
echo "apk_amd64_sha=ailurus-android-${APP_VERSION}-amd64.apk.sha256" >> "$GITHUB_OUTPUT"
- name: Restore Android keystore
run: |
echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 -d > android/release-keystore.jks
- name: Create key.properties
run: |
cat > android/key.properties <<EOF
storePassword=${{ secrets.ANDROID_STORE_PASSWORD }}
keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}
keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}
storeFile=release-keystore.jks
EOF
- name: Build signed Android APKs
run: flutter build apk --release --target-platform android-arm64,android-x64 --split-per-abi
- name: Verify APK signature
run: |
BUILD_TOOLS_VERSION=$(ls "$ANDROID_HOME/build-tools" | sort -V | tail -n 1)
"$ANDROID_HOME/build-tools/$BUILD_TOOLS_VERSION/apksigner" verify --print-certs build/app/outputs/flutter-apk/app-arm64-v8a-release.apk
"$ANDROID_HOME/build-tools/$BUILD_TOOLS_VERSION/apksigner" verify --print-certs build/app/outputs/flutter-apk/app-x86_64-release.apk
- name: Generate checksums
shell: bash
run: |
cp build/app/outputs/flutter-apk/app-arm64-v8a-release.apk "build/app/outputs/flutter-apk/${{ steps.android_meta.outputs.apk_arm64 }}"
cp build/app/outputs/flutter-apk/app-x86_64-release.apk "build/app/outputs/flutter-apk/${{ steps.android_meta.outputs.apk_amd64 }}"
sha256sum "build/app/outputs/flutter-apk/${{ steps.android_meta.outputs.apk_arm64 }}" > "build/app/outputs/flutter-apk/${{ steps.android_meta.outputs.apk_arm64_sha }}"
sha256sum "build/app/outputs/flutter-apk/${{ steps.android_meta.outputs.apk_amd64 }}" > "build/app/outputs/flutter-apk/${{ steps.android_meta.outputs.apk_amd64_sha }}"
- name: Upload Android artifact
uses: actions/upload-artifact@v4
with:
name: ailurus-android-signed
path: |
build/app/outputs/flutter-apk/${{ steps.android_meta.outputs.apk_arm64 }}
build/app/outputs/flutter-apk/${{ steps.android_meta.outputs.apk_arm64_sha }}
build/app/outputs/flutter-apk/${{ steps.android_meta.outputs.apk_amd64 }}
build/app/outputs/flutter-apk/${{ steps.android_meta.outputs.apk_amd64_sha }}
if-no-files-found: error
- name: Upload Android release assets
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1 || gh release create "${GITHUB_REF_NAME}" --generate-notes >/dev/null 2>&1 || true
gh release upload "${GITHUB_REF_NAME}" \
"build/app/outputs/flutter-apk/${{ steps.android_meta.outputs.apk_arm64 }}" \
"build/app/outputs/flutter-apk/${{ steps.android_meta.outputs.apk_arm64_sha }}" \
"build/app/outputs/flutter-apk/${{ steps.android_meta.outputs.apk_amd64 }}" \
"build/app/outputs/flutter-apk/${{ steps.android_meta.outputs.apk_amd64_sha }}" \
--clobber