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
81 changes: 81 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: CI Build Test

on:
pull_request:
branches: [master]
workflow_dispatch: # manual trigger from GitHub Actions UI

permissions:
contents: read

jobs:
build-deb:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- arch: amd64
docker_platform: linux/amd64
- arch: arm64
docker_platform: linux/arm64
- arch: armhf
docker_platform: linux/arm/v7

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Build .deb package
run: |
docker run --rm --platform ${{ matrix.docker_platform }} \
-v "$PWD":/build -w /build \
debian:bookworm bash -c '
set -e
apt-get update
apt-get install -y --no-install-recommends \
build-essential debhelper libudev-dev
dpkg-buildpackage -us -uc -b
echo "=== .deb build successful ==="
for deb in ../*.deb; do dpkg-deb --info "$deb"; done
'

build-rpm:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- arch: x86_64
docker_platform: linux/amd64
- arch: aarch64
docker_platform: linux/arm64

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Build .rpm package
run: |
docker run --rm --platform ${{ matrix.docker_platform }} \
-v "$PWD":/build -w /build \
rockylinux:9 bash -c '
set -e
dnf install -y gcc-c++ make systemd-devel rpm-build systemd-rpm-macros
mkdir -p /root/rpmbuild/{SOURCES,SPECS}
tar czf /root/rpmbuild/SOURCES/mediasmartserver-0.6.0.tar.gz \
--transform "s,^\.,mediasmartserver-0.6.0," \
--exclude=.git .
cp rpm/mediasmartserver.spec /root/rpmbuild/SPECS/
rpmbuild -bb --define "_version 0.6.0" /root/rpmbuild/SPECS/mediasmartserver.spec
echo "=== .rpm build successful ==="
rpm -qip /root/rpmbuild/RPMS/*/*.rpm
'
302 changes: 302 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,302 @@
name: Build & Release

on:
push:
tags:
- 'v*'

permissions:
contents: write
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- arch: amd64
docker_platform: linux/amd64
- arch: arm64
docker_platform: linux/arm64
- arch: armhf
docker_platform: linux/arm/v7

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"

- name: Build .deb package
run: |
docker run --rm --platform ${{ matrix.docker_platform }} \
-v "$PWD":/build -w /build \
debian:bookworm bash -c '
set -e
apt-get update
apt-get install -y --no-install-recommends \
build-essential debhelper libudev-dev
# Update changelog version from tag
sed -i "1s/([^)]*)/('"${{ steps.version.outputs.version }}"'-1)/" debian/changelog
dpkg-buildpackage -us -uc -b
mkdir -p output
mv ../*.deb output/
'

- name: Upload .deb artifact
uses: actions/upload-artifact@v4
with:
name: deb-${{ matrix.arch }}
path: output/*.deb

build-rpm:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- arch: x86_64
docker_platform: linux/amd64
- arch: aarch64
docker_platform: linux/arm64

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"

- name: Build .rpm package
run: |
docker run --rm --platform ${{ matrix.docker_platform }} \
-v "$PWD":/build -w /build \
rockylinux:9 bash -c '
set -e
dnf install -y gcc-c++ make systemd-devel rpm-build systemd-rpm-macros
VERSION='"${{ steps.version.outputs.version }}"'
# Create source tarball
mkdir -p /root/rpmbuild/{SOURCES,SPECS}
tar czf /root/rpmbuild/SOURCES/mediasmartserver-${VERSION}.tar.gz \
--transform "s,^\.,mediasmartserver-${VERSION}," \
--exclude=.git .
cp rpm/mediasmartserver.spec /root/rpmbuild/SPECS/
rpmbuild -bb --define "_version ${VERSION}" /root/rpmbuild/SPECS/mediasmartserver.spec
mkdir -p /build/output
cp /root/rpmbuild/RPMS/*/*.rpm /build/output/
'

- name: Upload .rpm artifact
uses: actions/upload-artifact@v4
with:
name: rpm-${{ matrix.arch }}
path: output/*.rpm

release:
needs: [build, build-rpm]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: packages
merge-multiple: true

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
packages/*.deb
packages/*.rpm
generate_release_notes: true

publish-repos:
needs: [build, build-rpm]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: gh-pages
fetch-depth: 0
continue-on-error: true

- name: Initialize gh-pages if needed
run: |
if [ ! -f index.html ]; then
git init
git checkout -b gh-pages
fi

- name: Download deb artifacts
uses: actions/download-artifact@v4
with:
pattern: deb-*
path: incoming-deb
merge-multiple: true

- name: Download rpm artifacts
uses: actions/download-artifact@v4
with:
pattern: rpm-*
path: incoming-rpm
merge-multiple: true

- name: Install repo tools
run: sudo apt-get update && sudo apt-get install -y reprepro createrepo-c

- name: Import or generate GPG key
run: |
if [ -n "${{ secrets.GPG_PRIVATE_KEY }}" ]; then
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format long | grep sec | head -1 | awk '{print $2}' | cut -d'/' -f2)
else
# Generate a temporary key for signing (user should replace with proper key)
cat > /tmp/gpg-batch <<GPGEOF
%no-protection
Key-Type: RSA
Key-Length: 4096
Subkey-Type: RSA
Subkey-Length: 4096
Name-Real: mediasmartserverd
Name-Email: amd989@users.noreply.github.com
Expire-Date: 0
GPGEOF
gpg --batch --gen-key /tmp/gpg-batch
GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format long | grep sec | head -1 | awk '{print $2}' | cut -d'/' -f2)
echo "::warning::Using auto-generated GPG key. For production, add GPG_PRIVATE_KEY secret."
fi
echo "GPG_KEY_ID=$GPG_KEY_ID" >> "$GITHUB_ENV"
gpg --armor --export "$GPG_KEY_ID" > gpg.key

- name: Configure reprepro
run: |
mkdir -p conf
cat > conf/distributions <<EOF
Origin: mediasmartserverd
Label: mediasmartserverd
Codename: stable
Architectures: amd64 arm64 armhf
Components: main
Description: LED status daemon for HP MediaSmart Server and compatible hardware
SignWith: ${{ env.GPG_KEY_ID }}
EOF

- name: Add deb packages to APT repo
run: |
for deb in incoming-deb/*.deb; do
reprepro includedeb stable "$deb"
done

- name: Create YUM/DNF repo
run: |
rm -rf rpm/packages rpm/repodata
mkdir -p rpm/packages
cp incoming-rpm/*.rpm rpm/packages/
gpg --batch --pinentry-mode loopback --detach-sign --armor rpm/packages/*.rpm 2>/dev/null || true
createrepo_c rpm/
gpg --batch --pinentry-mode loopback --detach-sign --armor rpm/repodata/repomd.xml

- name: Create index page
run: |
cat > index.html <<'HTMLEOF'
<!DOCTYPE html>
<html>
<head><title>mediasmartserverd Package Repository</title></head>
<body>
<h1>mediasmartserverd Package Repository</h1>

<h2>Debian / Ubuntu / Mint (apt)</h2>
<h3>Quick Install</h3>
<pre>
curl -fsSL https://amd989.github.io/mediasmartserverd/setup.sh | sudo bash
sudo apt install mediasmartserver
</pre>
<h3>Manual Setup</h3>
<pre>
curl -fsSL https://amd989.github.io/mediasmartserverd/gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/mediasmartserverd.gpg
echo "deb [signed-by=/usr/share/keyrings/mediasmartserverd.gpg] https://amd989.github.io/mediasmartserverd stable main" | sudo tee /etc/apt/sources.list.d/mediasmartserverd.list
sudo apt update
sudo apt install mediasmartserver
</pre>

<h2>Rocky Linux / RHEL / Fedora (dnf)</h2>
<h3>Quick Install</h3>
<pre>
curl -fsSL https://amd989.github.io/mediasmartserverd/setup-rpm.sh | sudo bash
sudo dnf install mediasmartserver
</pre>
<h3>Manual Setup</h3>
<pre>
sudo rpm --import https://amd989.github.io/mediasmartserverd/gpg.key
sudo tee /etc/yum.repos.d/mediasmartserverd.repo &lt;&lt;EOF
[mediasmartserverd]
name=mediasmartserverd
baseurl=https://amd989.github.io/mediasmartserverd/rpm/
enabled=1
gpgcheck=1
gpgkey=https://amd989.github.io/mediasmartserverd/gpg.key
EOF
sudo dnf install mediasmartserver
</pre>
</body>
</html>
HTMLEOF

- name: Create APT setup script
run: |
cat > setup.sh <<'SETUPEOF'
#!/bin/bash
set -e
echo "Adding mediasmartserverd APT repository..."
curl -fsSL https://amd989.github.io/mediasmartserverd/gpg.key | gpg --dearmor -o /usr/share/keyrings/mediasmartserverd.gpg
echo "deb [signed-by=/usr/share/keyrings/mediasmartserverd.gpg] https://amd989.github.io/mediasmartserverd stable main" > /etc/apt/sources.list.d/mediasmartserverd.list
apt-get update
echo "Done! You can now run: sudo apt install mediasmartserver"
SETUPEOF
chmod +x setup.sh

- name: Create DNF setup script
run: |
cat > setup-rpm.sh <<'SETUPEOF'
#!/bin/bash
set -e
echo "Adding mediasmartserverd YUM/DNF repository..."
rpm --import https://amd989.github.io/mediasmartserverd/gpg.key
cat > /etc/yum.repos.d/mediasmartserverd.repo <<REPOEOF
[mediasmartserverd]
name=mediasmartserverd
baseurl=https://amd989.github.io/mediasmartserverd/rpm/
enabled=1
gpgcheck=1
gpgkey=https://amd989.github.io/mediasmartserverd/gpg.key
REPOEOF
echo "Done! You can now run: sudo dnf install mediasmartserver"
SETUPEOF
chmod +x setup-rpm.sh

- name: Deploy to GitHub Pages
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Clean up build artifacts, keep repo files
rm -rf incoming-deb incoming-rpm conf
git add -A
git commit -m "Update package repo for ${GITHUB_REF_NAME}" || true
git push origin gh-pages --force
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading
Loading