Skip to content

Commit

Permalink
ci: enable snapcraft packaging (#22)
Browse files Browse the repository at this point in the history
* ci: refactor snapcraft

* fix: update the icon

* chore: add changelog entry

* fix style
  • Loading branch information
florianvazelle authored Dec 2, 2023
1 parent 29f5020 commit 0903c35
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 52 deletions.
53 changes: 35 additions & 18 deletions .github/workflows/snapcraft-build.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
## [Unreleased]
### Added
- Add web deploy ([#20](https://github.com/MechanicalFlower/Marble/pull/20))
- Add snapcraft packaging ([#22](https://github.com/MechanicalFlower/Marble/pull/22))
### Changed
- Use Justfile as command runner ([#18](https://github.com/MechanicalFlower/Marble/pull/18))
### Deprecated
Expand Down
6 changes: 6 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions assets/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.import
*.snap
2 changes: 1 addition & 1 deletion public/packaging/org.mechanicalflower.Marble.desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

[Desktop Entry]
Version=1.3
Version=1.4.2
Type=Application

Name=Marble
Expand Down
60 changes: 27 additions & 33 deletions public/packaging/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}/<file> 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}/<file> 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

0 comments on commit 0903c35

Please sign in to comment.