Skip to content

Commit 1f4e7f6

Browse files
committed
.github: refactor AppImage build, use helper script
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
1 parent 557e209 commit 1f4e7f6

File tree

2 files changed

+60
-42
lines changed

2 files changed

+60
-42
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -30,56 +30,21 @@ jobs:
3030
if [ "${{ matrix.arch }}" = "aarch64" ]; then
3131
docker run --rm --platform linux/arm64 \
3232
-v $PWD:/workspace -w /workspace \
33-
--entrypoint /bin/bash \
34-
ubuntu:22.04 -c '
33+
ubuntu:22.04 /bin/bash -c '
3534
apt-get update && \
36-
apt-get install -y wget file libfuse2 xxd libsdl2-dev libsdl2-ttf-dev \
37-
libsdl2-image-dev libsdl2-mixer-dev build-essential && \
35+
apt-get install -y xxd libsdl2-dev libsdl2-ttf-dev \
36+
libsdl2-image-dev libsdl2-mixer-dev build-essential squashfs-tools && \
3837
make clean && make && \
39-
(ARCH=aarch64 make appimage || (
40-
echo \"AppImage build failed, trying fallback...\" && \
41-
apt-get install -y squashfs-tools && \
42-
wget -q -c https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-aarch64.AppImage -O appimagetool.AppImage && \
43-
echo \"Extracting AppImage with unsquashfs...\" && \
44-
chmod +x appimagetool.AppImage && \
45-
./appimagetool.AppImage --appimage-extract 2>/dev/null || unsquashfs -d squashfs-root appimagetool.AppImage && \
46-
mkdir -p AppDir/usr/bin AppDir/usr/share/applications AppDir/usr/share/icons/hicolor/256x256/apps && \
47-
cp demo AppDir/usr/bin/ && \
48-
printf "[Desktop Entry]\nType=Application\nName=Infix Demo\nExec=usr/bin/demo\nIcon=demo\nCategories=Game;\n" > AppDir/usr/share/applications/demo.desktop
49-
cp jack.png AppDir/usr/share/icons/hicolor/256x256/apps/demo.png && \
50-
ln -sf usr/share/applications/demo.desktop AppDir/demo.desktop && \
51-
ln -sf usr/share/icons/hicolor/256x256/apps/demo.png AppDir/demo.png && \
52-
ln -sf usr/bin/demo AppDir/AppRun && \
53-
ARCH=aarch64 squashfs-root/AppRun AppDir InfixDemo-aarch64.AppImage && \
54-
rm -rf AppDir squashfs-root appimagetool.AppImage
55-
))
38+
./utils/build-appimage.sh aarch64
5639
'
5740
else
5841
sudo apt-get update
59-
sudo apt-get install -y libfuse2 libsdl2-dev libsdl2-ttf-dev \
60-
libsdl2-image-dev libsdl2-mixer-dev
42+
sudo apt-get install -y libsdl2-dev libsdl2-ttf-dev \
43+
libsdl2-image-dev libsdl2-mixer-dev squashfs-tools
6144
make clean && make
62-
# Extract and run appimagetool without FUSE
63-
make appimage || (
64-
wget -q -c https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool &&
65-
chmod +x appimagetool &&
66-
./appimagetool --appimage-extract &&
67-
mkdir -p AppDir/usr/bin AppDir/usr/share/applications AppDir/usr/share/icons/hicolor/256x256/apps &&
68-
cp demo AppDir/usr/bin/ &&
69-
printf "[Desktop Entry]\nType=Application\nName=Infix Demo\nExec=usr/bin/demo\nIcon=demo\nCategories=Game;\n" > AppDir/usr/share/applications/demo.desktop &&
70-
cp jack.png AppDir/usr/share/icons/hicolor/256x256/apps/demo.png &&
71-
ln -sf usr/share/applications/demo.desktop AppDir/demo.desktop &&
72-
ln -sf usr/share/icons/hicolor/256x256/apps/demo.png AppDir/demo.png &&
73-
ln -sf usr/bin/demo AppDir/AppRun &&
74-
ARCH=x86_64 squashfs-root/AppRun AppDir InfixDemo-x86_64.AppImage &&
75-
rm -rf AppDir squashfs-root appimagetool
76-
)
45+
./utils/build-appimage.sh x86_64
7746
fi
7847
79-
- name: Rename AppImage
80-
run: |
81-
mv InfixDemo-x86_64.AppImage InfixDemo-${{ matrix.arch }}.AppImage || true
82-
8348
- name: Upload AppImage artifact
8449
uses: actions/upload-artifact@v4
8550
with:

utils/build-appimage.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/sh
2+
# Build AppImage for any architecture
3+
# Usage: build-appimage.sh <arch>
4+
5+
set -e
6+
7+
ARCH=${1:-x86_64}
8+
APPIMAGE_NAME="InfixDemo-${ARCH}.AppImage"
9+
10+
echo "Building AppImage for ${ARCH}..."
11+
12+
# Create AppDir structure
13+
mkdir -p AppDir/usr/bin
14+
mkdir -p AppDir/usr/share/applications
15+
mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
16+
17+
# Copy binary
18+
cp demo AppDir/usr/bin/
19+
20+
# Create desktop file
21+
cat > AppDir/usr/share/applications/demo.desktop << 'EOF'
22+
[Desktop Entry]
23+
Type=Application
24+
Name=Infix Demo
25+
Exec=demo
26+
Icon=demo
27+
Categories=Game;
28+
EOF
29+
30+
# Copy icon
31+
cp jack.png AppDir/usr/share/icons/hicolor/256x256/apps/demo.png
32+
33+
# Create AppRun
34+
cat > AppDir/AppRun << 'EOF'
35+
#!/bin/sh
36+
SELF=$(readlink -f "$0")
37+
HERE=${SELF%/*}
38+
export PATH="${HERE}/usr/bin:${PATH}"
39+
export LD_LIBRARY_PATH="${HERE}/usr/lib:${LD_LIBRARY_PATH}"
40+
exec "${HERE}/usr/bin/demo" "$@"
41+
EOF
42+
43+
chmod +x AppDir/AppRun
44+
45+
# Create AppImage using mksquashfs
46+
echo "Creating ${APPIMAGE_NAME}..."
47+
mksquashfs AppDir "${APPIMAGE_NAME}" -root-owned -noappend
48+
chmod +x "${APPIMAGE_NAME}"
49+
50+
# Cleanup
51+
rm -rf AppDir
52+
53+
echo "AppImage created: ${APPIMAGE_NAME}"

0 commit comments

Comments
 (0)