Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
216 changes: 216 additions & 0 deletions .github/workflows/build-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
name: Build Packages

on:
workflow_call:
inputs:
expected-tag:
required: false
type: string
default: ''
if-no-files-found:
required: false
type: string
default: warn
outputs:
version:
description: Project version read from CMakeLists.txt
value: ${{ jobs.prepare.outputs.version }}

jobs:
prepare:
name: Prepare package build
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Read project version
id: version
run: |
VERSION="$(cmake -DPRINT_VERSION=ON -P packaging/sync-package-version.cmake)"

if [ -n "${{ inputs.expected-tag }}" ] && [ "${{ inputs.expected-tag }}" != "v${VERSION}" ]; then
echo "Tag ${{ inputs.expected-tag }} does not match project version ${VERSION}. Expected v${VERSION}."
exit 1
fi

echo "version=${VERSION}" >> "$GITHUB_OUTPUT"

- name: Verify package metadata version
run: cmake -DVERIFY_ONLY=ON -P packaging/sync-package-version.cmake

deb:
name: Debian packages (Ubuntu)
needs: prepare
runs-on: ubuntu-latest
container: ubuntu:25.04
strategy:
fail-fast: false
matrix:
component: [rdhm-agent, rdhm-monitor]
env:
DEBIAN_FRONTEND: noninteractive
steps:
- name: Install base tools
run: apt-get update && apt-get install -y git ca-certificates

- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install common build dependencies
run: |
apt-get install -y \
build-essential cmake pkg-config debhelper devscripts \
fakeroot dpkg-dev

- name: Install monitor build dependencies
if: matrix.component == 'rdhm-monitor'
run: |
apt-get install -y \
qt6-base-dev qt6-declarative-dev libqt6quickcontrols2-6 \
qt6-base-dev-tools qt6-declarative-dev-tools \
libavahi-client-dev qml6-module-qtquick \
qml6-module-qtquick-controls qml6-module-qtquick-layouts \
libgl1-mesa-dev

- name: Build package
run: |
VERSION="$(cmake -DPRINT_VERSION=ON -P packaging/sync-package-version.cmake)"
PKG_DIR=$(mktemp -d)
cp -a . "$PKG_DIR/${{ matrix.component }}-${VERSION}"
cp -a packaging/deb/${{ matrix.component }}/debian \
"$PKG_DIR/${{ matrix.component }}-${VERSION}/debian"
cd "$PKG_DIR/${{ matrix.component }}-${VERSION}"
dpkg-buildpackage -b -us -uc
mkdir -p /tmp/rdhm-packages
cp "$PKG_DIR"/*.deb /tmp/rdhm-packages/
ls -lh /tmp/rdhm-packages/*.deb

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: deb-${{ matrix.component }}
path: /tmp/rdhm-packages/*.deb
if-no-files-found: ${{ inputs.if-no-files-found }}

rpm:
name: RPM packages (Fedora)
needs: prepare
runs-on: ubuntu-latest
container: fedora:41
strategy:
fail-fast: false
matrix:
component: [rdhm-agent, rdhm-monitor]
steps:
- name: Install base tools
run: dnf install -y git

- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install common build dependencies
run: |
dnf install -y \
cmake gcc-c++ make rpm-build systemd-rpm-macros

- name: Install monitor build dependencies
if: matrix.component == 'rdhm-monitor'
run: |
dnf install -y \
qt6-qtbase-devel qt6-qtdeclarative-devel \
qt6-qtquickcontrols2-devel avahi-devel \
mesa-libGL-devel

- name: Build package
run: |
RPMBUILD_DIR=$(mktemp -d)
mkdir -p "$RPMBUILD_DIR"/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

SPEC="packaging/rpm/${{ matrix.component }}.spec"
VERSION="$(cmake -DPRINT_VERSION=ON -P packaging/sync-package-version.cmake)"
PKG_NAME="${{ matrix.component }}-${VERSION}"

tar czf "$RPMBUILD_DIR/SOURCES/${PKG_NAME}.tar.gz" \
--transform "s,^\.,${PKG_NAME}," \
--exclude='.git' --exclude='build' .

cp "$SPEC" "$RPMBUILD_DIR/SPECS/"

rpmbuild -bb \
--define "_topdir $RPMBUILD_DIR" \
"$RPMBUILD_DIR/SPECS/${{ matrix.component }}.spec"

mkdir -p /tmp/rdhm-packages
find "$RPMBUILD_DIR/RPMS/" -name '*.rpm' -exec cp {} /tmp/rdhm-packages/ \;
ls -lh /tmp/rdhm-packages/*.rpm

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rpm-${{ matrix.component }}
path: /tmp/rdhm-packages/*.rpm
if-no-files-found: ${{ inputs.if-no-files-found }}

pacman:
name: Pacman packages (Arch)
needs: prepare
runs-on: ubuntu-latest
container: archlinux:latest
strategy:
fail-fast: false
matrix:
component: [rdhm-agent, rdhm-monitor]
steps:
- name: Install base tools
run: |
pacman -Syu --noconfirm
pacman -S --noconfirm git base-devel cmake sudo

- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install monitor build dependencies
if: matrix.component == 'rdhm-monitor'
run: |
pacman -S --noconfirm \
qt6-base qt6-declarative avahi

- name: Build package
run: |
useradd -m builder
echo 'builder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

BUILD_DIR=$(mktemp -d)
PKGBUILD_DIR="packaging/arch/${{ matrix.component }}"
VERSION="$(cmake -DPRINT_VERSION=ON -P packaging/sync-package-version.cmake)"
PKG_NAME="${{ matrix.component }}-${VERSION}"

tar czf "$BUILD_DIR/${PKG_NAME}.tar.gz" \
--transform "s,^\.,${PKG_NAME}," \
--exclude='.git' --exclude='build' .

cp "$PKGBUILD_DIR"/* "$BUILD_DIR/"
test -f "$BUILD_DIR/${PKG_NAME}.tar.gz"
ls -lh "$BUILD_DIR/${PKG_NAME}.tar.gz"

chown -R builder:builder "$BUILD_DIR"
cd "$BUILD_DIR"
sudo -u builder makepkg -sf --noconfirm --skipchecksums

mkdir -p /tmp/rdhm-packages
cp "$BUILD_DIR"/*.pkg.tar.zst /tmp/rdhm-packages/
ls -lh /tmp/rdhm-packages/*.pkg.tar.zst

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: pacman-${{ matrix.component }}
path: /tmp/rdhm-packages/*.pkg.tar.zst
if-no-files-found: ${{ inputs.if-no-files-found }}
151 changes: 2 additions & 149 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,152 +3,5 @@ name: Package Build
on: [pull_request]

jobs:
deb:
name: Debian packages (Ubuntu)
runs-on: ubuntu-latest
container: ubuntu:25.04
strategy:
fail-fast: false
matrix:
component: [rdhm-agent, rdhm-monitor]
env:
DEBIAN_FRONTEND: noninteractive
steps:
- name: Install base tools
run: apt-get update && apt-get install -y git ca-certificates

- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install common build dependencies
run: |
apt-get install -y \
build-essential cmake pkg-config debhelper devscripts \
fakeroot dpkg-dev

- name: Install monitor build dependencies
if: matrix.component == 'rdhm-monitor'
run: |
apt-get install -y \
qt6-base-dev qt6-declarative-dev libqt6quickcontrols2-6 \
qt6-base-dev-tools qt6-declarative-dev-tools \
libavahi-client-dev qml6-module-qtquick \
qml6-module-qtquick-controls qml6-module-qtquick-layouts \
libgl1-mesa-dev

- name: Build package
run: |
PKG_DIR=$(mktemp -d)
cp -a . "$PKG_DIR/${{ matrix.component }}-${{ env.VERSION }}"
cp -a packaging/deb/${{ matrix.component }}/debian \
"$PKG_DIR/${{ matrix.component }}-${{ env.VERSION }}/debian"
cd "$PKG_DIR/${{ matrix.component }}-${{ env.VERSION }}"
dpkg-buildpackage -b -us -uc
ls -lh "$PKG_DIR"/*.deb
env:
VERSION: "0.2.0"

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: deb-${{ matrix.component }}
path: /tmp/tmp.*/**.deb
if-no-files-found: warn

rpm:
name: RPM packages (Fedora)
runs-on: ubuntu-latest
container: fedora:41
strategy:
fail-fast: false
matrix:
component: [rdhm-agent, rdhm-monitor]
steps:
- name: Install base tools
run: dnf install -y git

- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install common build dependencies
run: |
dnf install -y \
cmake gcc-c++ make rpm-build systemd-rpm-macros

- name: Install monitor build dependencies
if: matrix.component == 'rdhm-monitor'
run: |
dnf install -y \
qt6-qtbase-devel qt6-qtdeclarative-devel \
qt6-qtquickcontrols2-devel avahi-devel \
mesa-libGL-devel

- name: Build package
run: |
RPMBUILD_DIR=$(mktemp -d)
mkdir -p "$RPMBUILD_DIR"/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

SPEC="packaging/rpm/${{ matrix.component }}.spec"
VERSION=$(grep '^Version:' "$SPEC" | awk '{print $2}')
PKG_NAME="${{ matrix.component }}-${VERSION}"

tar czf "$RPMBUILD_DIR/SOURCES/${PKG_NAME}.tar.gz" \
--transform "s,^\.,${PKG_NAME}," \
--exclude='.git' --exclude='build' .

cp "$SPEC" "$RPMBUILD_DIR/SPECS/"

rpmbuild -bb \
--define "_topdir $RPMBUILD_DIR" \
"$RPMBUILD_DIR/SPECS/${{ matrix.component }}.spec"

find "$RPMBUILD_DIR/RPMS/" -name '*.rpm' -exec ls -lh {} \;

pacman:
name: Pacman packages (Arch)
runs-on: ubuntu-latest
container: archlinux:latest
strategy:
fail-fast: false
matrix:
component: [rdhm-agent, rdhm-monitor]
steps:
- name: Install base tools
run: |
pacman -Syu --noconfirm
pacman -S --noconfirm git base-devel cmake sudo

- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install monitor build dependencies
if: matrix.component == 'rdhm-monitor'
run: |
pacman -S --noconfirm \
qt6-base qt6-declarative avahi

- name: Build package
run: |
# makepkg refuses to run as root — create a build user
useradd -m builder
echo 'builder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

BUILD_DIR=$(mktemp -d)
PKGBUILD_DIR="packaging/arch/${{ matrix.component }}"
VERSION=$(grep '^pkgver=' "$PKGBUILD_DIR/PKGBUILD" | cut -d= -f2)
PKG_NAME="${{ matrix.component }}-${VERSION}"

# Create source tarball that makepkg expects
tar czf "$BUILD_DIR/${PKG_NAME}.tar.gz" \
--transform "s,^\.,${PKG_NAME}," \
--exclude='.git' --exclude='build' .

cp "$PKGBUILD_DIR"/* "$BUILD_DIR/"

chown -R builder:builder "$BUILD_DIR"
cd "$BUILD_DIR"
sudo -u builder makepkg -sf --noconfirm --skipchecksums
ls -lh "$BUILD_DIR"/*.pkg.tar.zst
packages:
uses: ./.github/workflows/build-packages.yml
Loading
Loading