-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (140 loc) · 5.74 KB
/
build-linux.yml
File metadata and controls
166 lines (140 loc) · 5.74 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
name: Build Linux (tar.gz + AppImage)
on:
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
jobs:
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"
# --------- Portable tar.gz (works on most distros, but deps may be needed) ----------
- 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"
# --------- AppImage (universal across Ubuntu/Debian/Arch/etc) ----------
- name: Build AppImage
id: appimage
shell: bash
run: |
set -e
VERSION="${{ steps.ver.outputs.version }}"
OUT_DIR="build/linux/x64/release/bundle"
# Tools
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
# AppDir layout
mkdir -p AppDir/usr/bin
cp -r "$OUT_DIR/"* AppDir/usr/bin/
# Try to find the main executable (Flutter usually uses the pubspec app name).
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
# Desktop file + icon (you can replace the icon with your own)
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
# Icon placeholder: try to use project icon, otherwise create a stub
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
# An empty icon is acceptable for AppImage build
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
# Build AppImage
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
# Rename output
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 }}