Skip to content

github: fix build-rpm-packages #8

github: fix build-rpm-packages

github: fix build-rpm-packages #8

name: Build RPM Packages
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: ["fedora:38", "fedora:37", "almalinux:9", "almalinux:8"]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache dnf packages
uses: actions/cache@v2
with:
path: /var/cache/dnf
key: ${{ runner.os }}-dnf-${{ hashFiles('**/Dockerfile') }}
restore-keys: |
${{ runner.os }}-dnf-
- name: Determine version and dist
id: version
run: |
# Get the most recent tag, and check if the latest commit is tagged
LATEST_TAG=$(git describe --tags --abbrev=0)
TAGGED_COMMIT=$(git describe --tags --exact-match 2>/dev/null || echo "notag")
if [ "$TAGGED_COMMIT" = "notag" ]; then
VERSION="${LATEST_TAG}+"
DIST="-git"
else
VERSION=$LATEST_TAG
DIST=""
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "DIST=$DIST" >> $GITHUB_ENV
- name: Build RPM packages in Docker
run: |
docker run --rm -v $(pwd):/workspace -w /workspace ${{ matrix.os }} /bin/bash -c "
sudo dnf install -y rpm-build dnf-plugins-core
sudo dnf builddep -y ~/rpmbuild/SPECS/xnec2c.spec || exit 1
./autogen.sh
./configure
make
mkdir -p ~/rpmbuild/SOURCES ~/rpmbuild/SPECS
mv . ~/rpmbuild/SOURCES/xnec2c-v${VERSION}
tar -czvf ~/rpmbuild/SOURCES/xnec2c-v${VERSION}.tar.gz -C ~/rpmbuild/SOURCES xnec2c-v${VERSION}
rpmbuild -ba -D \"_topdir $(pwd)/rpmbuild\" -D \"dist $DIST\" ~/rpmbuild/SPECS/xnec2c.spec
cp ~/rpmbuild/RPMS/x86_64/xnec2c-*.rpm ."
- name: Test RPM Package
run: |
docker run --rm -v $(pwd):/workspace -w /workspace ${{ matrix.os }} /bin/bash -c "
sudo dnf install -y ./xnec2c-*.rpm
xnec2c -h"
- name: Upload the RPM package
uses: actions/upload-artifact@v2
with:
name: xnec2c-${{ matrix.os }}.rpm
path: xnec2c-*.rpm