diff --git a/.github/workflows/release-gentoo.yml b/.github/workflows/release-gentoo.yml new file mode 100644 index 000000000..f51e97c0e --- /dev/null +++ b/.github/workflows/release-gentoo.yml @@ -0,0 +1,99 @@ +name: release-gentoo + +on: + workflow_run: + workflows: ["release-linux"] + types: [completed] + workflow_dispatch: + inputs: + version: + description: "Version to publish (e.g. 1.2.0)" + required: true + type: string + +concurrency: + group: gentoo-overlay + cancel-in-progress: false + +permissions: + contents: read + +jobs: + update-overlay: + runs-on: ubuntu-latest + if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && startsWith(github.event.workflow_run.head_branch, 'v') && !contains(github.event.workflow_run.head_branch, '-rc')) }} + steps: + - name: Checkout app repo + uses: actions/checkout@v4 + + - name: Determine version + id: version + env: + EVENT_NAME: ${{ github.event_name }} + WORKFLOW_HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} + DISPATCH_VERSION: ${{ inputs.version }} + run: | + if [[ "$EVENT_NAME" == "workflow_run" ]]; then + REF="$WORKFLOW_HEAD_BRANCH" + if [[ ! "$REF" =~ ^v[0-9]+(\.[0-9]+){1,3}([.-][0-9A-Za-z.-]+)?$ ]]; then + echo "Invalid tag: $REF" + exit 1 + fi + VERSION="${REF#v}" + else + VERSION="$DISPATCH_VERSION" + fi + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + echo "Version: $VERSION" + + - name: Clone overlay repo + env: + OVERLAY_PAT: ${{ secrets.OVERLAY_PAT }} + run: | + git clone "https://x-access-token:${OVERLAY_PAT}@github.com/vicrodh/qbz-overlay.git" /tmp/qbz-overlay + cd /tmp/qbz-overlay + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + + - name: Update binary ebuild + env: + VERSION: ${{ steps.version.outputs.version }} + run: | + cd /tmp/qbz-overlay/media-sound/qbz-bin + + # Remove old version ebuilds (keep metadata.xml) + rm -f qbz-bin-*.ebuild + + # Copy template from app repo and update version + cp "${{ github.workspace }}/packaging/gentoo/qbz-bin.ebuild.template" "qbz-bin-${VERSION}.ebuild" + + echo "=== qbz-bin-${VERSION}.ebuild ===" + cat "qbz-bin-${VERSION}.ebuild" + + - name: Update source ebuild + env: + VERSION: ${{ steps.version.outputs.version }} + run: | + cd /tmp/qbz-overlay/media-sound/qbz + + # Remove old version ebuilds (keep metadata.xml) + rm -f qbz-*.ebuild + + # Copy template from app repo and update version + cp "${{ github.workspace }}/packaging/gentoo/qbz.ebuild.template" "qbz-${VERSION}.ebuild" + + echo "=== qbz-${VERSION}.ebuild ===" + cat "qbz-${VERSION}.ebuild" + + - name: Commit and push + env: + VERSION: ${{ steps.version.outputs.version }} + run: | + cd /tmp/qbz-overlay + git add -A + if git diff --cached --quiet; then + echo "No changes to commit" + exit 0 + fi + git commit -m "Update to v${VERSION}" + git push diff --git a/packaging/gentoo/qbz-bin.ebuild.template b/packaging/gentoo/qbz-bin.ebuild.template new file mode 100644 index 000000000..eea280be5 --- /dev/null +++ b/packaging/gentoo/qbz-bin.ebuild.template @@ -0,0 +1,68 @@ +# Copyright 2024-2026 Gentoo Authors +# Distributed under the terms of the MIT License + +EAPI=8 + +DESCRIPTION="Native hi-fi Qobuz desktop player for Linux (prebuilt binary)" +HOMEPAGE="https://qbz.lol https://github.com/vicrodh/qbz" + +MY_PV="${PV}" +SRC_URI=" + amd64? ( https://github.com/vicrodh/qbz/releases/download/v${MY_PV}/qbz_${MY_PV}_amd64.tar.gz ) + arm64? ( https://github.com/vicrodh/qbz/releases/download/v${MY_PV}/qbz_${MY_PV}_aarch64.tar.gz ) +" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64 ~arm64" + +RDEPEND=" + net-libs/webkit-gtk:4.1 + x11-libs/gtk+:3 + media-libs/alsa-lib + dev-libs/openssl + dev-libs/libappindicator:3 + x11-libs/libxkbcommon +" + +BDEPEND="" + +# Binary package, no compilation needed +QA_PREBUILT="usr/bin/qbz" + +S="${WORKDIR}" + +src_unpack() { + default + # Tarball extracts to qbz_${PV}_${arch}/ directory + if use amd64; then + S="${WORKDIR}/qbz_${MY_PV}_amd64" + elif use arm64; then + S="${WORKDIR}/qbz_${MY_PV}_aarch64" + fi +} + +src_install() { + dobin qbz + + insinto /usr/share/applications + newins qbz.desktop qbz.desktop + + local size + for size in 32 48 64 128 256; do + if [[ -f "icons/hicolor/${size}x${size}/apps/qbz.png" ]]; then + insinto "/usr/share/icons/hicolor/${size}x${size}/apps" + doins "icons/hicolor/${size}x${size}/apps/qbz.png" + fi + done +} + +pkg_postinst() { + xdg_icon_cache_update + xdg_desktop_database_update +} + +pkg_postrm() { + xdg_icon_cache_update + xdg_desktop_database_update +} diff --git a/packaging/gentoo/qbz.ebuild.template b/packaging/gentoo/qbz.ebuild.template new file mode 100644 index 000000000..4b081892a --- /dev/null +++ b/packaging/gentoo/qbz.ebuild.template @@ -0,0 +1,114 @@ +# Copyright 2024-2026 Gentoo Authors +# Distributed under the terms of the MIT License + +EAPI=8 + +inherit cargo xdg + +DESCRIPTION="Native hi-fi Qobuz desktop player for Linux" +HOMEPAGE="https://qbz.lol https://github.com/vicrodh/qbz" + +MY_PV="${PV}" +SRC_URI=" + https://github.com/vicrodh/qbz/archive/refs/tags/v${MY_PV}.tar.gz -> ${P}.tar.gz + ${CARGO_CRATE_URIS} +" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64 ~arm64" +IUSE="pipewire pulseaudio" + +RDEPEND=" + net-libs/webkit-gtk:4.1 + x11-libs/gtk+:3 + media-libs/alsa-lib + dev-libs/openssl + dev-libs/libappindicator:3 + x11-libs/libxkbcommon + gnome-base/librsvg:2 + pipewire? ( + media-video/pipewire[alsa-plugin] + ) + pulseaudio? ( + media-libs/libpulse + ) +" + +BDEPEND=" + virtual/rust + net-libs/nodejs[npm] + sys-devel/clang + virtual/pkgconfig +" + +# alsa-utils improves device detection for bit-perfect playback +PDEPEND=" + media-sound/alsa-utils +" + +S="${WORKDIR}/qbz-${MY_PV}" + +src_prepare() { + default + + # Generate cargo config for offline build if needed + cargo_src_prepare +} + +src_configure() { + cargo_src_configure +} + +src_compile() { + # Build the SvelteKit frontend + npm ci --prefer-offline || die "npm ci failed" + npm run build || die "frontend build failed" + + # Build the Tauri/Rust backend (no bundler — we install manually) + cd src-tauri || die + cargo_src_compile --bin qbz +} + +src_install() { + # Install the binary + dobin "src-tauri/target/release/qbz" + + # Desktop file + insinto /usr/share/applications + newins packaging/arch/qbz.desktop qbz.desktop + + # Icons + local size + for size in 32 48 64 128 256; do + local src_icon="src-tauri/icons/${size}x${size}.png" + if [[ -f "${src_icon}" ]]; then + insinto "/usr/share/icons/hicolor/${size}x${size}/apps" + newins "${src_icon}" qbz.png + fi + done + + # Use the high-res icon as a fallback for missing sizes + local fallback="src-tauri/icons/128x128.png" + for size in 48 64; do + if [[ ! -f "src-tauri/icons/${size}x${size}.png" ]]; then + insinto "/usr/share/icons/hicolor/${size}x${size}/apps" + newins "${fallback}" qbz.png + fi + done +} + +pkg_postinst() { + xdg_icon_cache_update + xdg_desktop_database_update + + elog "For bit-perfect audio playback, ensure your user is in the 'audio' group:" + elog " usermod -aG audio \${USER}" + elog "" + elog "Optional: install media-sound/alsa-utils for better ALSA device detection." +} + +pkg_postrm() { + xdg_icon_cache_update + xdg_desktop_database_update +}