Skip to content

Commit

Permalink
build: add Flatpak packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
varungujarathi9 committed May 23, 2024
1 parent ce3abcb commit eed7ea5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ package-all:
docker-all:
BUILD --platform=linux/amd64 --platform=linux/386 --platform=linux/arm64 --platform=linux/arm/v7 +docker

flatpak-all:
BUILD +flatpak

crosscompiler:
# This image is missing a few platforms, so we'll add them locally
FROM --platform=linux/amd64 bdwyertech/go-crosscompile
Expand Down Expand Up @@ -142,6 +145,36 @@ docker:
SAVE IMAGE --push "${i}"
END

flatpak:
RUN apk add flatpak flatpak-builder
RUN flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
RUN flatpak install flathub org.freedesktop.Platform//23.08 org.freedesktop.Sdk//23.08 -y

ARG TARGETPLATFORM # provided by Earthly
IF [ "$TARGETPLATFORM" = "linux/amd64" ]
ARG NAME=linux-64bit
ELSE IF [ "$TARGETPLATFORM" = "linux/386" ]
ARG NAME=linux-32bit
ELSE IF [ "$TARGETPLATFORM" = "linux/arm64" ]
ARG NAME=linux-arm64
ELSE IF [ "$TARGETPLATFORM" = "linux/arm/v7" ]
ARG NAME=linux-arm7
ELSE IF [ "$TARGETPLATFORM" = "darwin/amd64" ]
ARG NAME=macOS-64bit
ELSE IF [ "$TARGETPLATFORM" = "darwin/arm64" ]
ARG NAME=macOS-arm64
ELSE
ARG NAME=custom
END

ENV FLATPAK_NAME owncast-$version-$NAME.flatpak
COPY (+build/owncast --platform $TARGETPLATFORM) /build/flatpak/owncast
COPY . /build
RUN flatpak-builder --force-clean --repo=owncast-repo build-dir online.owncast.Owncast.json # build flatpak package from JSON file
RUN flatpak build-bundle owncast-repo /build/flatpak/owncast.flatpak online.owncast.Owncast # create a single-file bundle of flatpak package

SAVE ARTIFACT --keep-ts /build/flatpak/owncast.flatpak owncast.flatpak AS LOCAL flatpak/$FLATPAK_NAME

dockerfile:
FROM DOCKERFILE -f Dockerfile .

Expand Down
21 changes: 21 additions & 0 deletions online.owncast.Owncast.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"app-id": "online.owncast.Owncast",
"runtime": "org.freedesktop.Platform",
"runtime-version": "23.08",
"sdk": "org.freedesktop.Sdk",
"command": "/app/owncast",
"modules": [
{
"name": "Owncast",
"buildsystem": "simple",
"build-commands": ["cp ./owncast /app/"],
"sources": [
{
"type": "file",
"path": "/build/flatpak/owncast"
}
]
}
],
"finish-args": ["--socket=x11", "--share=network"]
}

0 comments on commit eed7ea5

Please sign in to comment.