From b6d92cbbd903d76293f5050d359b7cc9e89ddf68 Mon Sep 17 00:00:00 2001 From: Chen Asraf Date: Sun, 27 Oct 2024 01:37:25 +0200 Subject: [PATCH] feat: snap build --- .github/workflows/flatpak.yaml | 4 +- .github/workflows/snapcraft.yaml | 30 ++++ org.redotengine.Redot.yaml | 10 +- snapcraft.yaml | 239 +++++++++++++++++++++++++++++++ 4 files changed, 274 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/snapcraft.yaml create mode 100644 snapcraft.yaml diff --git a/.github/workflows/flatpak.yaml b/.github/workflows/flatpak.yaml index fa832fb..e14cf50 100644 --- a/.github/workflows/flatpak.yaml +++ b/.github/workflows/flatpak.yaml @@ -3,10 +3,10 @@ on: branches: [master] pull_request: workflow_dispatch: -name: CI +name: Flatpak jobs: flatpak: - name: "Flatpak" + name: Flatpak Build runs-on: ubuntu-latest container: image: bilelmoussaoui/flatpak-github-actions:gnome-44 diff --git a/.github/workflows/snapcraft.yaml b/.github/workflows/snapcraft.yaml new file mode 100644 index 0000000..451360d --- /dev/null +++ b/.github/workflows/snapcraft.yaml @@ -0,0 +1,30 @@ +on: + push: + branches: [master] + pull_request: + workflow_dispatch: +name: Snap +jobs: + my-job: + name: Snapcraft Build + runs-on: ubuntu-latest + # env: + # SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }} + steps: + - name: Check out Git repository + uses: actions/checkout@v4 + + - name: Install Snapcraft + uses: samuelmeuli/action-snapcraft@v2 + + - name: Install LXD + uses: canonical/setup-lxd@main + + - name: Snapcraft Build + run: snapcraft + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: Redot.snap + path: redot*.snap diff --git a/org.redotengine.Redot.yaml b/org.redotengine.Redot.yaml index 0b1dbfc..b8a8dd0 100644 --- a/org.redotengine.Redot.yaml +++ b/org.redotengine.Redot.yaml @@ -130,14 +130,12 @@ modules: buildsystem: simple sources: + # Source code tarball - type: archive sha256: 9666e705375d46ef1ea0bd5495f49fd53acd53b7b9e862906b176816d0817c80 - url: https://github.com/Redot-Engine/redot-engine/archive/refs/tags/2024101114.tar.gz - # x-checker-data: - # type: anitya - # project-id: 373975 - # url-template: https://github.com/Redot-Engine/redot-engine/releases/download/$version/redot-linuxbsd.zip + url: https://github.com/Redot-Engine/redot-engine/archive/refs/tags/redot-4.3-beta.1.tar.gz + # Binary tarball - type: archive sha256: 758daf31d5a20bcaecb49452b6760c2bff0c6f91174146f3e815a174fedf9a94 url: https://github.com/Redot-Engine/redot-engine/releases/download/redot-4.3-beta.1/Redot_v4.3-beta.1_linux.x86_64.zip @@ -153,8 +151,6 @@ modules: path: org.redotengine.Redot.appdata.xml build-commands: - # - python3 /app/bin/scons $SCONS_FLAGS $SCONS_FLAGS_EXTRA target=editor -j "$FLATPAK_BUILDER_N_JOBS" - # - install -D -m755 bin/redot.linuxbsd.editor.* /app/bin/redot-bin - install -D -m755 Redot_*_linux.* /app/bin/redot-bin - install -D -m755 redot.sh /app/bin/redot # TODO remove once rebranding is released with proper linux dist files diff --git a/snapcraft.yaml b/snapcraft.yaml new file mode 100644 index 0000000..f05e59d --- /dev/null +++ b/snapcraft.yaml @@ -0,0 +1,239 @@ +name: redot +confinement: strict +base: core22 +adopt-info: metainfo +architectures: + - build-on: amd64 +source-code: https://github.com/Redot-Engine/org.redotengine.Redot +icon: icon.svg +license: MIT +title: Redot +type: app + +package-repositories: + - type: apt + url: http://archive.ubuntu.com/ubuntu/ + suites: [jammy] + components: [main, universe] + architectures: [amd64] + key-id: F6ECB3762474EDA9D21B7022871920D1991BC93C + key-server: keyserver.ubuntu.com + +parts: + # extensible-hooks: + # plugin: dump + # source: https://github.com/diddlesnaps/snapcraft-utils-library.git + # source-subdir: snapcraft-assets/extensible-hooks + # + # # Allows Redot and our tools to load faster by pre-caching its dependencies. + # # This should go after everything that actually has a dependency at snap runtime + # # (so things like executables or libraries, not our metainfo stuff). + # ld-precache: + # after: + # - extensible-hooks + # - redot + # - redot-runtime + # - vulkan + # - tools + # plugin: dump + # source: https://github.com/diddlesnaps/snapcraft-utils-library.git + # source-subdir: snapcraft-assets/ld-precache + + redot: + plugin: dump + source: https://github.com/Redot-Engine/redot-engine/releases/download/redot-4.3-beta.1/Redot_v4.3-beta.1_linux.x86_64.zip + # Handles scons build+installation accounting for the differences in Redot 3 + # and Redot 4 automatically. + override-build: | + craftctl default + ls -la $CRAFT_PART_INSTALL $CRAFT_PART_INSTALL/bin + cp Redot_*_linux.* bin/redot + cp -r bin $CRAFT_PART_INSTALL/bin + organize: + Redot_*: bin/redot + icon.svg: meta/gui/redot.svg + stage: + - bin/redot + - meta/gui/redot.svg + # prime: + # - -version.py + + redot-runtime: + plugin: nil + stage-packages: + - libgl1-mesa-glx + - libpulse0 + - libudev1 + - libx11-6 + - libxcursor1 + - libxi6 + - libxinerama1 + - libxrandr2 + - libgl1-mesa-dri + + # Used for metainfo + description: + plugin: dump + source: . + source-type: local + stage: + - README.md + prime: + - -README.md + + # This section is designed to minimize changes needed for different versions and channels of Redot. + # + # The `parse-info` file only needs to be present in one of the pull, build, or install stages. + # Therefore, we only need to generate our `metainfo.xml` file during the build stage and then + # disregard it. We choose the build stage because our `after` dependencies have already staged + # their components, allowing us to gather everything we need from `$CRAFT_STAGE`. + # + # The complexity arises from two main reasons: + # 1. We need to generate a desktop file with a different display name for Redot 3 and 4, and indicate + # whether it's a beta version. + # 2. There is no `craftctl set description=foo` command like there is for `version` and `grade`. + # This necessitates the creation of a `metainfo.xml` file, significantly complicating the process. + # + # The first issue could be addressed with a simpler script if the second issue were resolved. + metainfo: + plugin: nil + source: . + source-type: local + after: [redot, description] + parse-info: [org.redotengine.Redot.appdata.xml] + # For finding `version.py` + build-environment: + - PYTHONPATH: $CRAFT_STAGE + override-build: | + git clone git@github.com:Redot-Engine/redot-engine.git + cp redot-engine/misc/dist/linux/* ./ + organize: + org.redotengine.Redot.desktop: meta/gui/org.redotengine.Redot.desktop + + alsa-mixin: + plugin: dump + source: https://github.com/diddlesnaps/snapcraft-alsa.git + source-subdir: snapcraft-assets + build-packages: + - libasound2-dev + stage-packages: + - libasound2 + - libasound2-plugins + stage: + - etc/asound.conf + - snap/command-chain/alsa-launch + - usr/bin/yad* + - usr/lib/*/alsa-lib + - usr/lib/*/libFLAC* + - usr/lib/*/libasound* + - usr/lib/*/libasyncns* + - usr/lib/*/libdnsfile* + - usr/lib/*/libjack* + - usr/lib/*/libpulse* + - usr/lib/*/libsamplerate* + - usr/lib/*/libsndfile* + - usr/lib/*/libspeex* + - usr/lib/*/libvorbis* + - usr/lib/*/pulseaudio + - usr/share/alsa + + vulkan: + plugin: nil + stage-packages: + - mesa-vulkan-drivers + - libwayland-client0 + prime: + - usr/bin/mesa-overlay-control.py + - usr/lib/*/libLLVM* + - usr/lib/*/libVkLayer* + - usr/lib/*/libvulkan* + - usr/lib/*/libxcb-randr* + - usr/lib/x86_64-linux-gnu/libwayland-client* + - usr/share/drirc.d + - usr/share/vulkan + + # Debugging + tools: + plugin: nil + stage-packages: + - vulkan-tools + - mesa-utils + - pciutils + prime: + - usr/bin/glxgears* + - usr/bin/glxinfo* + - usr/bin/lspci + - usr/bin/vkcube + - usr/bin/vkcubepp + - usr/lib/*/libpci* + +layout: + # Audio + /usr/lib/x86_64-linux-gnu/alsa-lib: + bind: $SNAP/usr/lib/x86_64-linux-gnu/alsa-lib + /usr/share/alsa: + bind: $SNAP/usr/share/alsa + /usr/share/vulkan: + bind: $SNAP/usr/share/vulkan + # Vulkan + /usr/lib/x86_64-linux-gnu/libvulkan_intel.so: + bind-file: $SNAP/usr/lib/x86_64-linux-gnu/libvulkan_intel.so + /usr/lib/x86_64-linux-gnu/libvulkan_lvp.so: + bind-file: $SNAP/usr/lib/x86_64-linux-gnu/libvulkan_lvp.so + /usr/lib/x86_64-linux-gnu/libvulkan_radeon.so: + bind-file: $SNAP/usr/lib/x86_64-linux-gnu/libvulkan_radeon.so + /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0.0.0: + bind-file: $SNAP/usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0.0.0 + /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0: + symlink: $SNAP/usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0.0.0 + /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0: + bind-file: $SNAP/usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0 + /usr/lib/x86_64-linux-gnu/libxcb.so: + symlink: $SNAP/usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0 + /usr/lib/x86_64-linux-gnu/libxcb.so.1: + symlink: $SNAP/usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0 + /etc/ld.so.cache: + bind-file: $SNAP_DATA/etc/ld.so.cache + +environment: + HOME: $SNAP_USER_COMMON + VK_ICD_FILENAMES: /var/lib/snapd/lib/vulkan/icd.d/nvidia_icd.json:$SNAP/usr/share/vulkan/icd.d/radeon_icd.x86_64.json:$SNAP/usr/share/vulkan/icd.d/intel_icd.x86_64.json + +apps: + redot: + command-chain: [snap/command-chain/alsa-launch] + command: bin/redot + common-id: org.redotengine.Redot + plugs: + - alsa + - audio-playback + - audio-record + - browser-support + - daemon-notify + - desktop + - desktop-legacy + - gsettings + - hardware-observe + - home + - io-ports-control + - joystick + - kvm + - libvirt + - mount-observe + - network + - network-bind + - network-manager + - opengl + - pulseaudio + - removable-media + - screen-inhibit-control + - wayland + - x11 + + # For debugging + vkcube: + command: usr/bin/vkcube + glxinfo: + command: usr/bin/glxinfo + glxgears: + command: usr/bin/glxgears