-
Notifications
You must be signed in to change notification settings - Fork 0
445 lines (369 loc) · 14 KB
/
build-all.yml
File metadata and controls
445 lines (369 loc) · 14 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
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
name: Build All (bundle)
on:
workflow_dispatch:
permissions:
contents: read
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
jobs:
build-android:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Java (17)
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- name: Setup Flutter (stable)
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Flutter pub get
run: flutter pub get
- name: Build APK (release)
run: flutter build apk --release
- name: Read version from pubspec.yaml
id: ver
shell: bash
run: |
VERSION=$(grep '^version:' pubspec.yaml | awk '{print $2}' | cut -d'+' -f1)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Rename APK
id: apk
shell: bash
run: |
set -e
SRC_APK=$(ls -1 build/app/outputs/flutter-apk/*.apk | head -n 1)
VERSION="${{ steps.ver.outputs.version }}"
DEST_APK="LocalDrop-android-v${VERSION}.apk"
cp "$SRC_APK" "$DEST_APK"
echo "apk_path=$DEST_APK" >> "$GITHUB_OUTPUT"
- name: Upload Android artifact
uses: actions/upload-artifact@v6
with:
name: LocalDrop-android
path: ${{ steps.apk.outputs.apk_path }}
build-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Flutter (stable)
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Install Linux build deps
run: |
sudo apt-get update
sudo apt-get install -y \
clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev \
libfuse2 libglib2.0-0 libsecret-1-dev libmpv-dev python3-pil
- name: Flutter pub get
run: flutter pub get
- name: Build Linux (release)
run: flutter build linux --release
- name: Read version from pubspec.yaml
id: ver
shell: bash
run: |
VERSION=$(grep '^version:' pubspec.yaml | awk '{print $2}' | cut -d'+' -f1)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Create tar.gz bundle
id: tgz
shell: bash
run: |
set -e
VERSION="${{ steps.ver.outputs.version }}"
OUT_DIR="build/linux/x64/release/bundle"
if [ ! -d "$OUT_DIR" ]; then
echo "ERROR: bundle not found at $OUT_DIR"
ls -la build/linux/x64/release || true
exit 1
fi
TGZ="LocalDrop-linux-v${VERSION}.tar.gz"
tar -C "$OUT_DIR" -czf "$TGZ" .
echo "tgz_path=$TGZ" >> "$GITHUB_OUTPUT"
- name: Build AppImage
id: appimage
shell: bash
run: |
set -e
VERSION="${{ steps.ver.outputs.version }}"
OUT_DIR="build/linux/x64/release/bundle"
curl -L -o linuxdeploy-x86_64.AppImage \
https://github.com/linuxdeploy/linuxdeploy/releases/latest/download/linuxdeploy-x86_64.AppImage
# linuxdeploy-plugin-gtk has no GitHub releases; skip download.
GTK_PLUGIN_OK=0
if [ -f linuxdeploy-plugin-gtk-x86_64.AppImage ]; then
SIZE=$(stat -c%s linuxdeploy-plugin-gtk-x86_64.AppImage || echo 0)
if [ "$SIZE" -gt 1000000 ]; then
GTK_PLUGIN_OK=1
fi
fi
if [ "$GTK_PLUGIN_OK" -ne 1 ]; then
echo "WARN: linuxdeploy-plugin-gtk AppImage not available, building without GTK plugin"
fi
chmod +x linuxdeploy-x86_64.AppImage
if [ -f linuxdeploy-plugin-gtk-x86_64.AppImage ]; then
chmod +x linuxdeploy-plugin-gtk-x86_64.AppImage
fi
mkdir -p AppDir/usr/bin
cp -r "$OUT_DIR/"* AppDir/usr/bin/
APP_NAME="$(grep '^name:' pubspec.yaml | awk '{print $2}')"
APP_BIN="AppDir/usr/bin/$APP_NAME"
if [ ! -x "$APP_BIN" ]; then
APP_BIN="$(find AppDir/usr/bin -maxdepth 1 -type f -executable | head -n 1)"
fi
if [ -z "$APP_BIN" ]; then
echo "ERROR: cannot find main executable in AppDir/usr/bin"
ls -la AppDir/usr/bin || true
exit 1
fi
mkdir -p AppDir/usr/share/applications
cat > AppDir/usr/share/applications/localdrop.desktop <<EOF
[Desktop Entry]
Type=Application
Name=LocalDrop
Exec=$(basename "$APP_BIN")
Icon=localdrop
Categories=Utility;
EOF
mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
if [ -f "assets/icons/localdrop_app_icon.png" ]; then
python3 -c 'from PIL import Image; Image.open("assets/icons/localdrop_app_icon.png").resize((256, 256), Image.LANCZOS).save("AppDir/usr/share/icons/hicolor/256x256/apps/localdrop.png")'
else
printf '\x89PNG\r\n\x1a\n' > AppDir/usr/share/icons/hicolor/256x256/apps/localdrop.png
fi
export LINUXDEPLOY=./linuxdeploy-x86_64.AppImage
if [ "$GTK_PLUGIN_OK" -eq 1 ]; then
export LINUXDEPLOY_PLUGIN_GTK=./linuxdeploy-plugin-gtk-x86_64.AppImage
fi
if [ "$GTK_PLUGIN_OK" -eq 1 ]; then
./linuxdeploy-x86_64.AppImage \
--appdir AppDir \
--executable "$APP_BIN" \
--desktop-file AppDir/usr/share/applications/localdrop.desktop \
--icon-file AppDir/usr/share/icons/hicolor/256x256/apps/localdrop.png \
--plugin gtk \
--output appimage
else
./linuxdeploy-x86_64.AppImage \
--appdir AppDir \
--executable "$APP_BIN" \
--desktop-file AppDir/usr/share/applications/localdrop.desktop \
--icon-file AppDir/usr/share/icons/hicolor/256x256/apps/localdrop.png \
--output appimage
fi
APPIMAGE_OUT=$(ls -1 *.AppImage | head -n 1)
FINAL="LocalDrop-linux-v${VERSION}.AppImage"
mv "$APPIMAGE_OUT" "$FINAL"
chmod +x "$FINAL"
echo "appimage_path=$FINAL" >> "$GITHUB_OUTPUT"
- name: Upload Linux artifacts
uses: actions/upload-artifact@v6
with:
name: LocalDrop-linux
path: |
${{ steps.appimage.outputs.appimage_path }}
${{ steps.tgz.outputs.tgz_path }}
build-windows:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Flutter (stable)
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Flutter pub get
run: flutter pub get
- name: Build Windows (release)
run: flutter build windows --release
- name: Read version from pubspec.yaml
id: ver
shell: pwsh
run: |
$v = (Get-Content "pubspec.yaml" | Where-Object { $_ -match '^version:' } | ForEach-Object {
($_ -split ':')[1].Trim().Split(' ')[0]
} | Select-Object -First 1)
if (-not $v) { throw "Version not found in pubspec.yaml" }
$v = $v.Split('+')[0]
"version=$v" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
- name: Create ZIP from Release folder contents
id: zip
shell: pwsh
run: |
$sourceDir = "build/windows/x64/runner/Release"
if (-not (Test-Path $sourceDir)) { throw "Source folder not found: $sourceDir" }
$version = "${{ steps.ver.outputs.version }}"
$zipFile = "LocalDrop-win-v$version.zip"
if (Test-Path $zipFile) { Remove-Item $zipFile -Force }
Compress-Archive -Path (Join-Path $sourceDir '*') -DestinationPath $zipFile -Force
"zip_path=$zipFile" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
- name: Upload Windows artifact
uses: actions/upload-artifact@v6
with:
name: LocalDrop-windows
path: ${{ steps.zip.outputs.zip_path }}
build-macos-ios:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup Flutter (stable)
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- name: Flutter pub get
run: flutter pub get
- name: Prepare iOS no-codesign config
shell: bash
run: |
{
echo ""
echo "CODE_SIGN_ENTITLEMENTS="
echo "DEVELOPMENT_TEAM="
echo "PROVISIONING_PROFILE_SPECIFIER="
echo "CODE_SIGN_STYLE=Manual"
} >> ios/Flutter/Release.xcconfig
- name: Build iOS
run: flutter build ios --no-codesign
- name: Create IPA
shell: bash
run: |
VERSION=$(grep '^version:' pubspec.yaml | awk '{print $2}' | cut -d'+' -f1)
rm -rf Payload
mkdir -p Payload
cp -r build/ios/iphoneos/Runner.app Payload/
zip -r "LocalDrop-ios-v${VERSION}.ipa" Payload
- name: Build macOS (release)
run: flutter build macos --release
- name: Package DMG (drag & drop)
shell: bash
run: |
set -e
VERSION=$(grep '^version:' pubspec.yaml | awk '{print $2}' | cut -d'+' -f1)
APP_SRC="build/macos/Build/Products/Release/LocalDrop.app"
if [ ! -d "$APP_SRC" ]; then
echo "ERROR: macOS app not found at $APP_SRC"
ls -la build/macos/Build/Products/Release || true
exit 1
fi
STAGE_DIR="build/macos/dmg/LocalDrop"
rm -rf "build/macos/dmg"
mkdir -p "$STAGE_DIR"
ENTITLEMENTS_FILE="macos/Runner/Release.entitlements"
if [ ! -f "$ENTITLEMENTS_FILE" ]; then
echo "ERROR: entitlements file not found at $ENTITLEMENTS_FILE"
exit 1
fi
cp -R "$APP_SRC" "$STAGE_DIR/LocalDrop.app"
APP_BUNDLE="$STAGE_DIR/LocalDrop.app"
if [ -d "$APP_BUNDLE/Contents/Frameworks" ]; then
find "$APP_BUNDLE/Contents/Frameworks" -type d -name "*.framework" -print0 \
| while IFS= read -r -d '' fw; do
codesign --force --sign - "$fw" || true
done
find "$APP_BUNDLE/Contents/Frameworks" -type f \( -name "*.dylib" -o -name "*.so" \) -print0 \
| while IFS= read -r -d '' lib; do
codesign --force --sign - "$lib" || true
done
fi
codesign --force --sign - --entitlements "$ENTITLEMENTS_FILE" "$APP_BUNDLE"
codesign --verify --deep --strict "$APP_BUNDLE"
ENTITLEMENTS_DUMP=$(mktemp)
codesign -d --entitlements :- "$APP_BUNDLE" > "$ENTITLEMENTS_DUMP" 2>/dev/null
if ! grep -q "com.apple.security.files.user-selected.read-write" "$ENTITLEMENTS_DUMP"; then
echo "ERROR: staged macOS app is missing user-selected file access entitlements"
cat "$ENTITLEMENTS_DUMP"
exit 1
fi
ln -s /Applications "$STAGE_DIR/Applications"
RW_DMG="build/macos/dmg/LocalDrop-temp.dmg"
DMG_NAME="LocalDrop-macos-v${VERSION}.dmg"
rm -f "$RW_DMG" "$DMG_NAME"
hdiutil create \
-volname "LocalDrop" \
-srcfolder "$STAGE_DIR" \
-ov \
-format UDRW \
-fs HFS+ \
"$RW_DMG"
ATTACH_OUTPUT=$(hdiutil attach "$RW_DMG" -readwrite -noverify -noautoopen)
DEVICE=$(echo "$ATTACH_OUTPUT" | awk '/\/Volumes\/LocalDrop/{print $1; exit}')
if [ -z "$DEVICE" ]; then
echo "ERROR: failed to mount temporary DMG"
echo "$ATTACH_OUTPUT"
exit 1
fi
osascript <<'APPLESCRIPT'
tell application "Finder"
tell disk "LocalDrop"
open
tell container window
set current view to icon view
set toolbar visible to false
set statusbar visible to false
set bounds to {140, 140, 640, 360}
end tell
tell icon view options of container window
set arrangement to not arranged
set icon size to 88
set text size to 13
end tell
set position of item "LocalDrop.app" of container window to {140, 95}
set position of item "Applications" of container window to {360, 95}
update without registering applications
delay 2
close
end tell
end tell
APPLESCRIPT
sync
hdiutil detach "$DEVICE"
hdiutil convert \
"$RW_DMG" \
-ov \
-format UDZO \
-imagekey zlib-level=9 \
-o "$DMG_NAME"
rm -f "$RW_DMG"
echo "Created $DMG_NAME"
- name: Upload iOS artifact
uses: actions/upload-artifact@v6
with:
name: LocalDrop-ios
path: LocalDrop-ios-v*.ipa
- name: Upload macOS artifact
uses: actions/upload-artifact@v6
with:
name: LocalDrop-macos
path: LocalDrop-macos-v*.dmg
package-all:
runs-on: ubuntu-latest
needs: [build-android, build-linux, build-windows, build-macos-ios]
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Read version from pubspec.yaml
id: ver
shell: bash
run: |
VERSION=$(grep '^version:' pubspec.yaml | awk '{print $2}' | cut -d'+' -f1)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Upload bundle artifact
uses: actions/upload-artifact@v6
with:
name: LocalDrop-all
path: dist/*