From 8659b8201120c6b9df20fb7b6d5ec3a1dba7e1f7 Mon Sep 17 00:00:00 2001 From: florianvazelle Date: Sat, 2 Dec 2023 19:32:40 +0100 Subject: [PATCH] ci: refactor snapcraft --- .github/workflows/snapcraft-build.yaml | 53 ++++++++++------ Justfile | 6 ++ public/.gitignore | 1 + .../org.mechanicalflower.Marble.desktop | 2 +- public/packaging/snap/snapcraft.yaml | 60 +++++++++---------- 5 files changed, 70 insertions(+), 52 deletions(-) diff --git a/.github/workflows/snapcraft-build.yaml b/.github/workflows/snapcraft-build.yaml index 0f1737c..2475b82 100644 --- a/.github/workflows/snapcraft-build.yaml +++ b/.github/workflows/snapcraft-build.yaml @@ -1,29 +1,46 @@ - -name: "Snapcraft build" +name: Snapcraft Build on: + push: workflow_dispatch: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 + timeout-minutes: 30 + steps: - - name: Checkout repository - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + - uses: extractions/setup-just@v1 + + - name: Load dotenv + run: just bump-version - - name: Build snap package - uses: snapcore/action-build@v1 - id: snapcraft + - name: Build snap package + uses: snapcore/action-build@v1 + working-directory: public/packaging + id: snapcraft - - name: Install built snap package - run: | - sudo snap install --dangerous ${{ steps.snapcraft.outputs.snap }} + # Push, on each commit of the main branch, to the edge channel + - uses: snapcore/action-publish@v1 + if: github.ref == 'refs/heads/main' + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }} + with: + snap: ${{ steps.snapcraft.outputs.snap }} + release: edge - - name: Install dependencies for test launch - run: | - sudo apt install -y mesa-utils libgl1-mesa-dri libglx-mesa0 + - name: Update the snapcraft to be stable + if: startsWith(github.ref, 'refs/tags/') + run: | + sed -i "s,grade:\ devel$,grade:\ stable\",g" ./public/packaging/snap/snapcraft.yaml + sed -i "s,confinement:\ devmode$,confinement:\ strict,g" ./public/packaging/snap/snapcraft.yaml - - name: Test marble launch - uses: GabrielBB/xvfb-action@v1.6 - with: - run: /bin/bash public/packaging/snap/snap-xvfb-launch.sh + # Push, on each tag, to the stable channel + - uses: snapcore/action-publish@v1 + if: startsWith(github.ref, 'refs/tags/') + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }} + with: + snap: ${{ steps.snapcraft.outputs.snap }} + release: stable \ No newline at end of file diff --git a/Justfile b/Justfile index 8f06522..7601dbe 100644 --- a/Justfile +++ b/Justfile @@ -111,6 +111,12 @@ import-resources: sed -i "s,application/version=.*$,application/version=\"{{ game_version }}\",g" ./export_presets.cfg sed -i "s,application/short_version=.*$,application/short_version=\"{{ short_version }}\",g" ./export_presets.cfg + echo "Update version in public/packaging" + sed -i "s,version:\ '.*'$,version:\ '{{ game_version }}',g" ./public/packaging/snap/snapcraft.yaml + sed -i "s,archive/refs/tags/.*\.tar\.gz$,archive/refs/tags/{{ game_version }}\.tar\.gz,g" ./public/packaging/snap/snapcraft.yaml + sed -i "s,releases/download/.*/Marble-linux-v.*\.zip$,releases/download/{{ game_version }}/Marble-linux-v{{ game_version }}\.zip,g" ./public/packaging/snap/snapcraft.yaml + sed -i "s,Version=.*$,Version={{ game_version }},g" ./public/packaging/org.mechanicalflower.Marble.desktop + echo "Create the override.cfg" touch override.cfg echo '[build_info]\npackage/version="{{ game_version }}"\npackage/build_date="{{ build_date }}"\nsource/commit="{{ commit_hash }}"' > override.cfg diff --git a/public/.gitignore b/public/.gitignore index e4fdbdb..51cc275 100644 --- a/public/.gitignore +++ b/public/.gitignore @@ -1 +1,2 @@ *.import +*.snap \ No newline at end of file diff --git a/public/packaging/org.mechanicalflower.Marble.desktop b/public/packaging/org.mechanicalflower.Marble.desktop index 6dab2d4..48c618d 100644 --- a/public/packaging/org.mechanicalflower.Marble.desktop +++ b/public/packaging/org.mechanicalflower.Marble.desktop @@ -1,6 +1,6 @@ [Desktop Entry] -Version=1.3 +Version=1.4.2 Type=Application Name=Marble diff --git a/public/packaging/snap/snapcraft.yaml b/public/packaging/snap/snapcraft.yaml index 00609e0..ec16d3a 100644 --- a/public/packaging/snap/snapcraft.yaml +++ b/public/packaging/snap/snapcraft.yaml @@ -2,56 +2,50 @@ --- name: marble base: core20 -version: '1.3' +version: '1.4.2' summary: A marble race minigame description: | A marble race minigame, made with Godot Engine. grade: devel confinement: devmode +license: MIT +architectures: [amd64] apps: marble: - command: usr/share/marble/Marble.x86_64 --main-pack $SNAP/usr/share/marble/Marble.pck -S $SNAP_USER_COMMON/save + command: Marble.x86_64 --main-pack $SNAP/Marble.pck --rendering-driver opengl3 + extensions: [gnome-3-38] plugs: - - home - pulseaudio - opengl - - screen-inhibit-control - - browser-support - x11 - # desktop: /usr/share/applications/org.mechanicalflower.Marble.desktop + desktop: org.mechanicalflower.Marble.desktop environment: - LIBGL_DRIVERS_PATH: $SNAP/usr/lib/${SNAPCRAFT_ARCH_TRIPLET}/dri + LD_LIBRARY_PATH: "$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio:$SNAP" parts: - marble: - source: . + marble-source: + source: https://github.com/MechanicalFlower/Marble/archive/refs/tags/1.4.2.tar.gz override-build: | - # Icon paths in the desktop file will be rewritten to use ${SNAP}/ if specified as desktop file in snapcraft.yaml - sed -i.bak -e "s|Icon=org.mechanicalflower.Marble$|Icon=meta/gui/icon.png|g" ${SNAPCRAFT_PART_SRC}/.github/org.mechanicalflower.Marble.desktop snapcraftctl build - mkdir -p ${SNAPCRAFT_PART_INSTALL}/usr/share/marble/ - cp ${SNAPCRAFT_PART_SRC}/Marble.x86_64 ${SNAPCRAFT_PART_INSTALL}/usr/share/marble/Marble.x86_64 - cp ${SNAPCRAFT_PART_SRC}/Marble.pck ${SNAPCRAFT_PART_INSTALL}/usr/share/marble/Marble.pck + + # Icon paths in the desktop file will be rewritten to use ${SNAP}/ if specified as desktop file in snapcraft.yaml + sed -i.bak -e "s|Icon=org.mechanicalflower.Marble$|Icon=gui/icon.png|g" ${SNAPCRAFT_PART_SRC}/public/packaging/org.mechanicalflower.Marble.desktop + + cp ${SNAPCRAFT_PART_SRC}/public/packaging/org.mechanicalflower.Marble.desktop ${SNAPCRAFT_PART_INSTALL}/org.mechanicalflower.Marble.desktop plugin: nil override-prime: | snapcraftctl prime - mkdir -p ${SNAPCRAFT_PRIME}/meta/gui - # cp ${SNAPCRAFT_PART_SRC}/org.mechanicalflower.Marble-256.png ${SNAPCRAFT_PRIME}/meta/gui/icon.png - stage-packages: - - libgl1 - - libglvnd0 - - libglx0 - - libx11-6 - - libxau6 - - libxcb1 - - libxcursor1 - - libxdmcp6 - - libxext6 - - libxfixes3 - - libxi6 - - libxinerama1 - - libxrandr2 - - libxrender1 - - libasound2 - - libpulse0 + + mkdir -p ${SNAPCRAFT_PRIME}/gui + cp ${SNAPCRAFT_PART_SRC}/assets/icon.png ${SNAPCRAFT_PRIME}/gui/icon.png + marble-dist: + source: https://github.com/MechanicalFlower/Marble/releases/download/1.4.2/Marble-linux-v1.4.2.zip + override-build: | + snapcraftctl build + + cp ${SNAPCRAFT_PART_SRC}/Marble.x86_64 ${SNAPCRAFT_PART_INSTALL}/Marble.x86_64 + cp ${SNAPCRAFT_PART_SRC}/Marble.pck ${SNAPCRAFT_PART_INSTALL}/Marble.pck + + chmod +x ${SNAPCRAFT_PART_INSTALL}/Marble.x86_64 + plugin: nil