Skip to content

Commit

Permalink
feat: snap build
Browse files Browse the repository at this point in the history
  • Loading branch information
chenasraf committed Oct 28, 2024
1 parent 9678604 commit b6d92cb
Show file tree
Hide file tree
Showing 4 changed files with 274 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/flatpak.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 3 additions & 7 deletions org.redotengine.Redot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
239 changes: 239 additions & 0 deletions snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -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 [email protected]: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

0 comments on commit b6d92cb

Please sign in to comment.