feat: Add snap support (#23)

* WIP: snapcraft config

* chore: tidy up snap workflow

* fix: update ld_library_path

* fix the version of the snap

This uses a combination of most recent git tag and short rev.

* Add git as a build package

Required because we have a dump plugin and a nill plugin which pull in next to nothing. Making it hard to do a version stamp without the git command
This commit is contained in:
Alan Pope 2024-07-24 19:23:58 +01:00 committed by GitHub
commit 0eba5601d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 94 additions and 0 deletions

38
.github/workflows/test-snap-builds.yml vendored Normal file
View file

@ -0,0 +1,38 @@
name: 🧪 Test snap builds on x86_64
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build snap
uses: snapcore/action-build@v1
id: snapcraft
- name: Show log on build failure
if: ${{ failure() }}
run: |
cat /home/runner/.local/state/snapcraft/log/snapcraft*.log
exit 1
- name: Review snap
uses: diddlesnaps/snapcraft-review-action@v1
with:
snap: ${{ steps.snapcraft.outputs.snap }}
isClassic: 'false'
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: 'snap'
path: ${{ steps.snapcraft.outputs.snap}}

56
snap/snapcraft.yaml Normal file
View file

@ -0,0 +1,56 @@
name: stream-sprout
base: core24
adopt-info: stream-sprout
summary: Restream video to multiple destinations
description: |
Restream a video source to multiple destinations such as Twitch, YouTube,
and Owncast
grade: stable
confinement: strict
platforms:
amd64:
build-on: [ amd64 ]
build-for: [ amd64 ]
arm64:
build-on: [ arm64 ]
build-for: [arm64 ]
armhf:
build-on: [ armhf ]
build-for: [ armhf ]
parts:
stream-sprout:
after: [ deps ]
plugin: dump
source: .
build-packages:
- git
override-pull: |
craftctl default
craftctl set version=$(git describe --tags --abbrev=0).$(git rev-parse --short HEAD)
prime:
- stream-sprout
- stream-sprout.yaml.example
- LICENSE
- SECURITY.md
deps:
plugin: nil
stage-packages:
- ffmpeg
- sed
- awk
- grep
apps:
stream-sprout:
command: stream-sprout
environment:
LD_LIBRARY_PATH: $SNAP/usr/lib/$CRAFT_ARCH_BUILD_FOR/pulseaudio:$SNAP/usr/lib/$CRAFT_ARCH_BUILD_FOR/blas:$SNAP/usr/lib/$CRAFT_ARCH_BUILD_FOR/lapack
plugs:
- home
- removable-media
- network-bind
- network