feat: add linux AppImage build support (#168)

---------

Co-authored-by: raojinlin <1239015423@qq.com>
Co-authored-by: raojinlin <raojinlin302@gmail.com>
This commit is contained in:
raojinlin 2024-03-01 10:15:15 +08:00 committed by GitHub
parent b46cc6c436
commit b745b9f45d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 57 additions and 3 deletions

View File

@ -13,11 +13,12 @@ on:
jobs:
release:
name: Release Linux App
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
platform:
- linux/amd64
steps:
- name: Checkout source code
uses: actions/checkout@v3
@ -29,6 +30,15 @@ jobs:
tag=$(echo ${{ matrix.platform }} | sed -e 's/\//_/g')
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Normalise platform arch
id: normalise_platform_arch
run: |
if [ "${{ matrix.platform }}" == "linux/amd64" ]; then
echo "arch=x86_64" >> "$GITHUB_OUTPUT"
elif [ "${{ matrix.platform }}" == "linux/aarch64" ]; then
echo "arch=aarch64" >> "$GITHUB_OUTPUT"
fi
- name: Normalise version tag
id: normalise_version
shell: bash
@ -54,7 +64,7 @@ jobs:
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libfuse-dev libfuse2
- name: Setup Node
uses: actions/setup-node@v3
@ -109,13 +119,57 @@ jobs:
sed -i 's/0.0.0/${{ steps.normalise_version.outputs.version }}/g' "tiny-rdm_${{ steps.normalise_version.outputs.version }}_amd64/DEBIAN/control"
dpkg-deb --build -Zxz "tiny-rdm_${{ steps.normalise_version.outputs.version }}_amd64"
- name: Package up appimage file
run: |
curl https://github.com/linuxdeploy/linuxdeploy/releases/download/1-alpha-20240109-1/linuxdeploy-${{ steps.normalise_platform_arch.outputs.arch }}.AppImage \
-o linuxdeploy \
-L
chmod u+x linuxdeploy
./linuxdeploy --appdir AppDir
pushd AppDir
# Copy WebKit files.
find /usr/lib* -name WebKitNetworkProcess -exec mkdir -p $(dirname '{}') \; -exec cp --parents '{}' "." \; || true
find /usr/lib* -name WebKitWebProcess -exec mkdir -p $(dirname '{}') \; -exec cp --parents '{}' "." \; || true
find /usr/lib* -name libwebkit2gtkinjectedbundle.so -exec mkdir -p $(dirname '{}') \; -exec cp --parents '{}' "." \; || true
popd
mkdir -p AppDir/usr/share/icons/hicolor/512x512/apps
build_dir="build/linux/tiny-rdm_${{ steps.normalise_version.outputs.version }}_amd64"
cp -r $build_dir/usr/share/icons/hicolor/512x512/apps/tiny-rdm.png AppDir/usr/share/icons/hicolor/512x512/apps/
cp $build_dir/usr/local/bin/tiny-rdm AppDir/usr/bin/
sed -i 's#/usr/local/bin/tiny-rdm#tiny-rdm#g' $build_dir/usr/share/applications/tiny-rdm.desktop
curl -o linuxdeploy-plugin-gtk.sh "https://raw.githubusercontent.com/tauri-apps/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh"
sed -i '/XDG_DATA_DIRS/a export WEBKIT_DISABLE_COMPOSITING_MODE=1' linuxdeploy-plugin-gtk.sh
chmod +x linuxdeploy-plugin-gtk.sh
curl -o AppDir/AppRun https://github.com/AppImage/AppImageKit/releases/download/continuous/AppRun-${{ steps.normalise_platform_arch.outputs.arch }} -L
./linuxdeploy --appdir AppDir \
--output=appimage \
--plugin=gtk \
-e $build_dir/usr/local/bin/tiny-rdm \
-d $build_dir/usr/share/applications/tiny-rdm.desktop
- name: Rename deb
working-directory: ./build/linux
run: mv "tiny-rdm_${{ steps.normalise_version.outputs.version }}_amd64.deb" "tiny-rdm_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.deb"
- name: Rename appimage
run: mv Tiny_RDM-${{ steps.normalise_platform_arch.outputs.arch }}.AppImage "tiny-rdm_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.AppImage"
- name: Upload release asset
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.normalise_version.outputs.version }}
files: ./build/linux/tiny-rdm_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.deb
files: |
./build/linux/tiny-rdm_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.deb
tiny-rdm_${{ steps.normalise_version.outputs.version }}_${{ steps.normalise_platform.outputs.tag }}.AppImage
token: ${{ secrets.GITHUB_TOKEN }}