Add flatpak packaging

This commit is contained in:
Jeena 2025-06-09 23:03:08 +09:00
parent b0582b7781
commit 382cc39b80
4 changed files with 170 additions and 0 deletions

View file

@ -0,0 +1,42 @@
app-id: net.jeena.Recoder
runtime: org.gnome.Platform
runtime-version: "48"
sdk: org.gnome.Sdk
command: recoder
finish-args:
- --filesystem=home
- --filesystem=/mnt
- --filesystem=/media
- --filesystem=/run/media
- --filesystem=xdg-data/sounds:ro
- --filesystem=~/.local/share/sounds/recoder:ro
- --socket=wayland
- --socket=x11
- --socket=pulseaudio
- --talk-name=org.freedesktop.Notifications
- --env=GSETTINGS_SCHEMA_DIR=/app/share/glib-2.0/schemas
- --device=dri
add-extensions:
org.freedesktop.Platform.ffmpeg-full:
version: "24.08"
directory: lib/ffmpeg
add-ld-path: .
modules:
- name: recoder
buildsystem: simple
builddir: true
sources:
- type: dir
path: ../../
build-commands:
- glib-compile-resources src/resources/resources.xml --target=src/recoder/resources.gresource --sourcedir=src/resources
- pip3 install --prefix=/app --no-deps --no-build-isolation .
- install -Dm644 src/resources/net.jeena.Recoder.desktop /app/share/applications/net.jeena.Recoder.desktop
- install -Dm644 src/resources/net.jeena.Recoder.svg /app/share/icons/hicolor/scalable/apps/net.jeena.Recoder.svg
- install -Dm644 src/resources/net.jeena.recoder.gschema.xml /app/share/glib-2.0/schemas/net.jeena.recoder.gschema.xml
- install -Dm644 src/resources/complete.oga /app/share/sounds/complete.oga
- install -Dm644 src/resources/net.jeena.Recoder.metainfo.xml /app/share/metainfo/net.jeena.Recoder.metainfo.xml
- glib-compile-schemas /app/share/glib-2.0/schemas

View file

@ -0,0 +1,68 @@
#!/usr/bin/env bash
set -euo pipefail
APP_ID="net.jeena.Recoder"
MANIFEST="${APP_ID}.yaml"
REPO_DIR="repo"
BRANCH="gh-pages"
WORKTREE_DIR="../../gh-pages"
PUBLISH_SUBDIR="flatpak-repo"
GPG_KEY_ID="1DF6570C929E2C186685046F0D6A8E36B9EE6177"
# Clean previous build
rm -rf build-dir "${REPO_DIR}"
# Build Flatpak and create signed repo
flatpak-builder --force-clean \
--repo="${REPO_DIR}" \
--default-branch=stable \
--gpg-sign="${GPG_KEY_ID}" \
build-dir "${MANIFEST}"
# Export public key into repo (also used below for flatpakref)
gpg --export --armor "${GPG_KEY_ID}" > "${REPO_DIR}/gpg.key"
# Clean up existing worktree if any
if [ -d "${WORKTREE_DIR}" ]; then
echo "Removing existing worktree at ${WORKTREE_DIR}..."
git worktree remove --force "${WORKTREE_DIR}"
rm -rf "${WORKTREE_DIR}"
fi
# Prepare gh-pages worktree
git fetch origin "${BRANCH}" || true
git worktree add -B "${BRANCH}" "${WORKTREE_DIR}" "origin/${BRANCH}"
# Clear just the publish subdir inside the worktree
rm -rf "${WORKTREE_DIR:?}/${PUBLISH_SUBDIR}"
mkdir -p "${WORKTREE_DIR}/${PUBLISH_SUBDIR}"
# Copy repo files into the publish subdir
cp -r "${REPO_DIR}/"* "${WORKTREE_DIR}/${PUBLISH_SUBDIR}/"
# Generate .flatpakref inside worktree root
cat > "${WORKTREE_DIR}/${APP_ID}.flatpakref" <<EOF
[Flatpak Ref]
Title=Recoder
Name=${APP_ID}
Branch=stable
Url=https://jeena.github.io/recoder/${PUBLISH_SUBDIR}
IsRuntime=false
RuntimeRepo=https://flathub.org/repo/flathub.flatpakrepo
GPGKey=$(base64 -w0 < "${REPO_DIR}/gpg.key")
EOF
# Get version
VERSION=$(python3 -c 'import toml; print(toml.load("../../pyproject.toml")["project"]["version"])')
# Commit and push only the publish subdir and flatpakref
pushd "${WORKTREE_DIR}" > /dev/null
git add "${PUBLISH_SUBDIR}" "${APP_ID}.flatpakref"
git commit -m "Update Flatpak release to version ${VERSION}" || echo "No changes to commit"
git push origin "${BRANCH}"
popd > /dev/null
# Clean up worktree
git worktree remove "${WORKTREE_DIR}"
echo "✅ Release uploaded to GitHub Pages with GPG signing!"