From 03d65d0e247d7522273becbd49ad615302d79295 Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 7 Oct 2023 14:43:50 +0200 Subject: [PATCH] Add AppImage builder workflow (#17) --- .dockerignore | 3 + .github/workflows/appimage.yml | 100 +++++++++++++++++++++++++++++++++ .github/workflows/meson.yml | 7 +-- Dockerfile | 26 +++++++++ dist/AppImageBuilder.yml | 54 ++++++++++++++++++ dist/linuxmotehook2.png | Bin 0 -> 2700 bytes 6 files changed, 186 insertions(+), 4 deletions(-) create mode 100644 .dockerignore create mode 100644 .github/workflows/appimage.yml create mode 100644 Dockerfile create mode 100644 dist/AppImageBuilder.yml create mode 100644 dist/linuxmotehook2.png diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..04f3214 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +.git +.github +Dockerfile diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml new file mode 100644 index 0000000..b95c537 --- /dev/null +++ b/.github/workflows/appimage.yml @@ -0,0 +1,100 @@ +name: Build and publish AppImages + +env: + UBUNTU_RELEASE: jammy + UBUNTU_PUBKEY: 871920D1991BC93C + +on: + pull_request: + push: + branches: main + release: + types: published + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + fail-fast: true + matrix: + platform: + - linux/amd64 + - linux/arm64 + + steps: + - uses: actions/checkout@v4 + - uses: rlespinasse/github-slug-action@v4 + + - name: Setup qemu for docker + uses: docker/setup-qemu-action@v2 + if: matrix.platform != 'linux/amd64' + + - name: Setup buildx for docker + uses: docker/setup-buildx-action@v2 + + - name: Compile in docker + uses: docker/build-push-action@v4 + with: + platforms: ${{ matrix.platform }} + outputs: build + build-args: | + UBUNTU_RELEASE + + - name: Prepare environment for building AppImage + env: + TARGET_PLATFORM: ${{ matrix.platform }} + shell: bash + run: | + set -eua + . build/.build-metadata.env + rm build/.build-metadata.env + APPIMAGE_SOURCE=build + APPIMAGE_VERSION="${GITHUB_REF_SLUG}" + APPIMAGE_APT_ARCH="${TARGETARCH}" + APPIMAGE_APT_DISTRO="${UBUNTU_RELEASE}" + APPIMAGE_APT_PUBKEY="${UBUNTU_PUBKEY}" + APPIMAGE_ARCH="${TARGETMACHINE}" + printenv | grep ^APPIMAGE_ >>"${GITHUB_ENV}" + + - name: Build AppImage + uses: AppImageCrafters/build-appimage@v1.3 + with: + recipe: dist/AppImageBuilder.yml + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: appimages + path: | + ./*.AppImage + ./*.AppImage.zsync + if-no-files-found: error + + release: + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + + needs: + - build + + permissions: + contents: write + + steps: + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: appimages + path: assets + - name: Create checksum for release assets + shell: bash + run: | + algo="${SHA_ALGORITHM:-256}" + find assets -type f | while read -r asset; do + shasum --binary --algorithm "${algo}" "${asset}" >"${asset}.sha${algo}" + done + - name: Upload artifacts to GitHub release + uses: softprops/action-gh-release@v1 + with: + files: assets/* diff --git a/.github/workflows/meson.yml b/.github/workflows/meson.yml index d8c9c52..40db9aa 100644 --- a/.github/workflows/meson.yml +++ b/.github/workflows/meson.yml @@ -1,10 +1,9 @@ -name: Meson +name: Native build on: push: branches: [ "main" ] pull_request: - branches: [ "main" ] env: # Customize the Meson build type here (plain, debug, debugoptimized, release, minsize, custom) @@ -16,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install dependencies uses: awalsh128/cache-apt-pkgs-action@latest @@ -25,7 +24,7 @@ jobs: version: 1.0 - name: Setup build directory - run: meson setup ${{github.workspace}}/build --fatal-meson-warnings --buildtype=${{env.BUILD_TYPE}} -Db_lto=${{env.ENABLE_LTO}} + run: meson setup ${{github.workspace}}/build --fatal-meson-warnings --buildtype=${{env.BUILD_TYPE}} -Db_lto=${{env.ENABLE_LTO}} - name: Build run: meson compile -C ${{github.workspace}}/build diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f251533 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +ARG UBUNTU_RELEASE=jammy + +FROM ubuntu:$UBUNTU_RELEASE AS build-stage +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + git ca-certificates build-essential libudev-dev zlib1g-dev valac libgee-0.8-dev meson + +COPY . / + +ARG BUILD_TYPE=release +ARG ENABLE_LTO=true +ARG TARGETOS TARGETARCH TARGETVARIANT + +RUN meson setup \ + --fatal-meson-warnings \ + "--buildtype=${BUILD_TYPE}" \ + "-Db_lto=${ENABLE_LTO}" \ + --prefix=/usr \ + /build && \ + meson compile -C /build && \ + meson install --destdir=/release -C /build + +RUN export "TARGETMACHINE=$(uname -m)" && \ + printenv | grep ^TARGET >>/release/.build-metadata.env + +FROM scratch AS export-stage +COPY --from=build-stage /release/ /release/.build-metadata.env / diff --git a/dist/AppImageBuilder.yml b/dist/AppImageBuilder.yml new file mode 100644 index 0000000..d766c7a --- /dev/null +++ b/dist/AppImageBuilder.yml @@ -0,0 +1,54 @@ +version: 1 + +script: +- | + mv "{{APPIMAGE_SOURCE}}" "${TARGET_APPDIR}" + icon_path="${TARGET_APPDIR}/usr/share/icons/hicolor/128x128/apps" + mkdir -p "${icon_path}" + cp -a dist/linuxmotehook2.png "${icon_path}" + # Manual installation is required until fix of https://github.com/AppImageCrafters/build-appimage/issues/5 + if ! command -v mksquashfs >/dev/null; then + apt-get update && apt-get install -y --no-install-recommends squashfs-tools + fi + +AppDir: + app_info: + id: org.v1993.linuxmotehook2 + name: linuxmotehook2 + version: "{{APPIMAGE_VERSION}}" + icon: linuxmotehook2 + exec: usr/bin/linuxmotehook2 + exec_args: $@ + + after_runtime: | + echo "X-AppImage-Integrate=false" >> "${TARGET_APPDIR}/org.v1993.linuxmotehook2.desktop" + + apt: + arch: + - "{{APPIMAGE_APT_ARCH}}" + sources: + - sourceline: deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ "{{APPIMAGE_APT_DISTRO}}" main + key_url: "http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x{{APPIMAGE_APT_PUBKEY}}" + - sourceline: deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ "{{APPIMAGE_APT_DISTRO}}"-updates main + - sourceline: deb [arch=amd64] http://security.ubuntu.com/ubuntu/ "{{APPIMAGE_APT_DISTRO}}"-security main + - sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ "{{APPIMAGE_APT_DISTRO}}" main + - sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ "{{APPIMAGE_APT_DISTRO}}"-updates main + - sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ "{{APPIMAGE_APT_DISTRO}}"-security main + include: + - libudev1 + - libglib2.0-0 + - libgee-0.8-2 + + files: + exclude: + - usr/share/man + - usr/share/doc/*/README.* + - usr/share/doc/*/changelog.* + - usr/share/doc/*/NEWS.* + - usr/share/doc/*/TODO.* + - usr/share/lintian + - usr/lib/*/glib-2.0 + +AppImage: + arch: "{{APPIMAGE_ARCH}}" + update-information: "gh-releases-zsync|v1993|linuxmotehook2|latest|linuxmotehook2-*-{{APPIMAGE_ARCH}}.AppImage.zsync" diff --git a/dist/linuxmotehook2.png b/dist/linuxmotehook2.png new file mode 100644 index 0000000000000000000000000000000000000000..2e7243e25820811ceb86a73971d5627aa8dd18e5 GIT binary patch literal 2700 zcmZ9Oc{CJ?7srPg426+3Gnt{X^hD7z_RLU521#Z_mdV(%4U>J0(vu}yGWJASGl}eL zvc(Ho!en2vWW1JP)ENA{KYr)@e(#?1x%ZxX|GDRW|F}2S()^0BkgN~@01(EQ7+D>} z$bSIy9(Xf*b`Ai*^S}d*w#1;(2tR*cR}U{D0HB;gNzpUuxCHBRyk1jStvq4aDUZHe z6(5K6l#H{K9~Gi&XV`Q2u(FROq_4Es%+2)>KDBq*;skJp5H5gpmt;jwIkKNFb+a?r zZz?HhTQ2AuApe?k)+fzF?v36>se)&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