-
Notifications
You must be signed in to change notification settings - Fork 0
239 lines (211 loc) · 8.85 KB
/
Copy pathbuild-linux.yml
File metadata and controls
239 lines (211 loc) · 8.85 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
name: Build Linux (tar.gz + AppImage + deb)
on:
workflow_dispatch:
env:
APP_NAME: LocalDrop
PUBSPEC_APP_NAME: localdrop
LINUX_APP_ID: com.algorithm.localdrop
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 --no-install-recommends \
clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev \
libfuse2 libglib2.0-0 python3-pil librsvg2-common
- 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 ----------
- name: Create tar.gz bundle
id: tgz
shell: bash
run: |
set -euo pipefail
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="${APP_NAME}-linux-v${VERSION}.tar.gz"
tar -C "$OUT_DIR" -czf "$TGZ" .
echo "tgz_path=$TGZ" >> "$GITHUB_OUTPUT"
# --------- AppImage ----------
- name: Build AppImage
id: appimage
shell: bash
run: |
set -euo pipefail
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
chmod +x linuxdeploy-x86_64.AppImage
# linuxdeploy-plugin-gtk is published as a raw script (no GitHub
# release). Pull it so GTK theme/loader libraries get bundled and the
# AppImage renders correctly on systems without a matching GTK stack.
GTK_PLUGIN_OK=0
if curl -fsSL -o linuxdeploy-plugin-gtk.sh \
https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh; then
chmod +x linuxdeploy-plugin-gtk.sh
GTK_PLUGIN_OK=1
else
echo "WARN: could not fetch linuxdeploy-plugin-gtk; building without it"
fi
rm -rf AppDir
mkdir -p AppDir/usr/bin
cp -r "$OUT_DIR/"* AppDir/usr/bin/
APP_BIN="AppDir/usr/bin/${PUBSPEC_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/${LINUX_APP_ID}.desktop" <<EOAPP
[Desktop Entry]
Type=Application
Name=${APP_NAME}
Exec=$(basename "$APP_BIN")
Icon=${LINUX_APP_ID}
Categories=Utility;Network;
StartupWMClass=${APP_NAME}
EOAPP
mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
ICON_PATH="AppDir/usr/share/icons/hicolor/256x256/apps/${LINUX_APP_ID}.png"
if [ -f "assets/icons/localdrop_app_icon.png" ]; then
ICON_SOURCE="assets/icons/localdrop_app_icon.png"
elif [ -f "linux/runner/resources/logo.png" ]; then
ICON_SOURCE="linux/runner/resources/logo.png"
else
echo "ERROR: no app icon found at assets/icons/localdrop_app_icon.png"
exit 1
fi
python3 -c "from PIL import Image; Image.open('$ICON_SOURCE').convert('RGBA').resize((256, 256), Image.LANCZOS).save('$ICON_PATH')"
# Name the output deterministically via linuxdeploy's OUTPUT env var
# so we never have to guess the produced filename.
FINAL="${APP_NAME}-linux-v${VERSION}.AppImage"
export OUTPUT="$FINAL"
export LINUXDEPLOY=./linuxdeploy-x86_64.AppImage
if [ "$GTK_PLUGIN_OK" -eq 1 ]; then
export LINUXDEPLOY_PLUGIN_GTK=./linuxdeploy-plugin-gtk.sh
./linuxdeploy-x86_64.AppImage \
--appdir AppDir \
--executable "$APP_BIN" \
--desktop-file "AppDir/usr/share/applications/${LINUX_APP_ID}.desktop" \
--icon-file "$ICON_PATH" \
--plugin gtk \
--output appimage
else
./linuxdeploy-x86_64.AppImage \
--appdir AppDir \
--executable "$APP_BIN" \
--desktop-file "AppDir/usr/share/applications/${LINUX_APP_ID}.desktop" \
--icon-file "$ICON_PATH" \
--output appimage
fi
if [ ! -f "$FINAL" ]; then
echo "ERROR: AppImage not produced at $FINAL"
ls -la *.AppImage || true
exit 1
fi
chmod +x "$FINAL"
echo "appimage_path=$FINAL" >> "$GITHUB_OUTPUT"
# --------- Debian package ----------
- name: Build .deb package
id: deb
shell: bash
run: |
set -euo pipefail
VERSION="${{ steps.ver.outputs.version }}"
OUT_DIR="build/linux/x64/release/bundle"
PKG="${PUBSPEC_APP_NAME}"
DEB_DIR="deb/${PKG}"
rm -rf deb
mkdir -p "$DEB_DIR/DEBIAN" \
"$DEB_DIR/usr/lib/${PKG}" \
"$DEB_DIR/usr/bin" \
"$DEB_DIR/usr/share/applications" \
"$DEB_DIR/usr/share/icons/hicolor/256x256/apps"
cp -r "$OUT_DIR/"* "$DEB_DIR/usr/lib/${PKG}/"
ln -s "/usr/lib/${PKG}/${PKG}" "$DEB_DIR/usr/bin/${PKG}"
cat > "$DEB_DIR/usr/share/applications/${LINUX_APP_ID}.desktop" <<EOF
[Desktop Entry]
Type=Application
Name=${APP_NAME}
Exec=${PKG}
Icon=${LINUX_APP_ID}
Categories=Utility;Network;
StartupWMClass=${APP_NAME}
EOF
if [ -f "assets/icons/localdrop_app_icon.png" ]; then ICON_SRC="assets/icons/localdrop_app_icon.png"
elif [ -f "linux/runner/resources/logo.png" ]; then ICON_SRC="linux/runner/resources/logo.png"
else echo "ERROR: no source icon for .deb"; exit 1; fi
mkdir -p "$DEB_DIR/usr/share/pixmaps"
for sz in 16 32 48 64 128 256 512; do
d="$DEB_DIR/usr/share/icons/hicolor/${sz}x${sz}/apps"
mkdir -p "$d"
python3 -c "from PIL import Image; Image.open('$ICON_SRC').convert('RGBA').resize(($sz,$sz), Image.LANCZOS).save('$d/${LINUX_APP_ID}.png')"
done
cp "$DEB_DIR/usr/share/icons/hicolor/256x256/apps/${LINUX_APP_ID}.png" \
"$DEB_DIR/usr/share/pixmaps/${LINUX_APP_ID}.png"
cat > "$DEB_DIR/DEBIAN/postinst" <<'EOF'
#!/bin/sh
set -e
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
gtk-update-icon-cache -f -t /usr/share/icons/hicolor >/dev/null 2>&1 || true
fi
if command -v update-desktop-database >/dev/null 2>&1; then
update-desktop-database -q /usr/share/applications >/dev/null 2>&1 || true
fi
exit 0
EOF
cp "$DEB_DIR/DEBIAN/postinst" "$DEB_DIR/DEBIAN/postrm"
chmod 0755 "$DEB_DIR/DEBIAN/postinst" "$DEB_DIR/DEBIAN/postrm"
INSTALLED_KB=$(du -sk "$DEB_DIR/usr" | cut -f1)
cat > "$DEB_DIR/DEBIAN/control" <<EOF
Package: ${PKG}
Version: ${VERSION}
Section: utils
Priority: optional
Architecture: amd64
Maintainer: Algorithm LLC <avagyanerik13@gmail.com>
Installed-Size: ${INSTALLED_KB}
Depends: libgtk-3-0, libglib2.0-0, libgl1, libegl1
Description: ${APP_NAME} local file sharing
Send files, folders, photos, videos, and text directly over your
local network with receiver approval.
EOF
DEB="${APP_NAME}-linux-v${VERSION}.deb"
dpkg-deb --build --root-owner-group "$DEB_DIR" "$DEB"
echo "deb_path=$DEB" >> "$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 }}
${{ steps.deb.outputs.deb_path }}