diff --git a/.github/workflows/appimage.yaml b/.github/workflows/appimage.yaml new file mode 100644 index 0000000..cc17cbb --- /dev/null +++ b/.github/workflows/appimage.yaml @@ -0,0 +1,41 @@ +# Copyright 2024 the Cartero authors +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# SPDX-License-Identifier: GPL-3.0-or-later + +on: + pull_request: + branches: + - trunk +name: AppImage +jobs: + stable: + name: Build (default profile) + runs-on: ubuntu-24.04 + steps: + - name: Install dependencies + run: sudo apt update && sudo apt install -y --no-install-recommends gettext meson libgtk-4-dev libadwaita-1-dev libgtksourceview-5-dev desktop-file-utils xvfb + - uses: actions/checkout@v4 + - name: Build + run: build-aux/appimage-build.sh stable + devel: + name: Build (development profile) + runs-on: ubuntu-24.04 + steps: + - name: Install dependencies + run: sudo apt update && sudo apt install -y --no-install-recommends gettext meson libgtk-4-dev libadwaita-1-dev libgtksourceview-5-dev desktop-file-utils xvfb + - uses: actions/checkout@v4 + - name: Build + run: build-aux/appimage-build.sh stable \ No newline at end of file diff --git a/build-aux/appimage-build.sh b/build-aux/appimage-build.sh new file mode 100755 index 0000000..06406cd --- /dev/null +++ b/build-aux/appimage-build.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +set -e +cd "$(dirname "$0")/.." + +case "$1" in + devel) + MESON_FLAGS="-Dprofile=development" + ICON_PATH="AppDir/usr/share/icons/hicolor/scalable/apps/es.danirod.Cartero.Devel.svg" + DESKTOP_PATH="AppDir/usr/share/applications/es.danirod.Cartero.Devel.desktop" + ;; + stable) + MESON_FLAGS="-Dprofile=default" + ICON_PATH="AppDir/usr/share/icons/hicolor/scalable/apps/es.danirod.Cartero.svg" + DESKTOP_PATH="AppDir/usr/share/applications/es.danirod.Cartero.desktop" + ;; + *) + echo "Usage: $0 [devel / stable]" + exit 1 + ;; +esac + +meson setup build --prefix="/" $MESON_FLAGS +ninja -C build +DESTDIR=$PWD/build/appimagetool/AppDir/usr ninja -C build install + +cd build/appimagetool +[ -x appimagetool-x86_64.AppImage ] || curl -OL https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage +[ -x linuxdeploy-x86_64.AppImage ] || curl -OL https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage +[ -x linuxdeploy-plugin-gtk.sh ] || curl -OL https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh +chmod +x appimagetool-x86_64.AppImage linuxdeploy-x86_64.AppImage linuxdeploy-plugin-gtk.sh + +DEPLOY_GTK_VERSION=4 + +export DEPLOY_GTK_VERSION + +# First iteration +./linuxdeploy-x86_64.AppImage --appdir AppDir --plugin gtk --output appimage \ + --executable AppDir/usr/bin/cartero \ + --icon-file "$ICON_PATH" \ + --desktop-file "$DESKTOP_PATH" + +# Patch the hook in order to support Adwaita theme. +sed -i '/GTK_THEME/d' AppDir/apprun-hooks/linuxdeploy-plugin-gtk.sh +sed -i '/GDK_BACKEND/d' AppDir/apprun-hooks/linuxdeploy-plugin-gtk.sh + +# Recompile with the changes. +./appimagetool-x86_64.AppImage AppDir \ No newline at end of file