debian-forge/.github/workflows/build_rpms.yml
Tom Gundersen 9d0f6bd85e github: build RPMs without git checkout
Make RPM building more similar to how RPMs will be built in koji.

This downloads the specfile from github at the given commit, appends
the commit sha to the specfile and uses spectools to download the
correct sources from github.

This should be equivalent to what is done in the makefile, the only
behavioral difference is that the rpms are now versioned based on
the git sha they are built from.

The main purpose of this change is to avoid any differences between
the CI and the real RPMs due to bugs in the Makefile. Correctly
versioned RPMs will also be handy for testing/debugging/deployment.

Signed-off-by: Tom Gundersen <teg@jklm.no>
2020-02-25 16:13:31 +01:00

75 lines
2.1 KiB
YAML

name: RPM Build
# NOTE(mhayden): Restricting branches prevents jobs from being doubled since
# a push to a pull request triggers two events.
on:
pull_request:
branches:
- "*"
push:
branches:
- master
jobs:
rpm_build:
name: "Build RPMs"
runs-on: ubuntu-latest
strategy:
matrix:
fedora_release: ["31", "32", "rawhide"]
container:
image: "docker.io/library/fedora:${{ matrix.fedora_release }}"
steps:
- name: Prepare container
run: |
echo "fastestmirror=1" >> /etc/dnf/dnf.conf
echo "install_weak_deps=0" >> /etc/dnf/dnf.conf
dnf -y upgrade
dnf -y install dnf-plugins-core rpm-build rpmdevtools
- name: Fetch .spec file
run: |
mkdir spec
# Fetch the spec file at the given commit, and prepend the commit sha to it
curl "https://raw.githubusercontent.com/osbuild/osbuild/${GITHUB_SHA}/osbuild.spec" -o osbuild.spec
echo "%global commit ${GITHUB_SHA}" | cat - osbuild.spec > spec/osbuild.spec
- name: Install RPM build dependencies
run: dnf -y builddep spec/osbuild.spec
- name: Fetch sources
run: |
mkdir sources
spectool -g spec/osbuild.spec -C sources/
- name: Build SRPM
run: |
mkdir srpms
rpmbuild -bs \
--define "_sourcedir sources" \
--define "_srcrpmdir srpms" \
spec/osbuild.spec
- name: Build RPMs
run: |
mkdir rpmbuild rpms build
rpmbuild -bb \
--define "_sourcedir `pwd`/sources" \
--define "_specdir `pwd`/spec" \
--define "_builddir `pwd`/rpmbuild" \
--define "_srcrpmdir `pwd`/srpms" \
--define "_rpmdir `pwd`/rpms" \
--define "_buildrootdir `pwd`/build" \
spec/osbuild.spec
- name: "Upload artifacts"
uses: actions/upload-artifact@v1
with:
name: rpms
path: rpms/
- name: Test RPM installation
run: |
pushd rpms/noarch
dnf -y install $(ls *.rpm)
popd