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>
This commit is contained in:
Tom Gundersen 2020-02-24 22:20:45 +01:00 committed by David Rheinsberg
parent d24d594173
commit 9d0f6bd85e

View file

@ -25,33 +25,51 @@ jobs:
echo "fastestmirror=1" >> /etc/dnf/dnf.conf echo "fastestmirror=1" >> /etc/dnf/dnf.conf
echo "install_weak_deps=0" >> /etc/dnf/dnf.conf echo "install_weak_deps=0" >> /etc/dnf/dnf.conf
dnf -y upgrade dnf -y upgrade
dnf -y install dnf-plugins-core git make rpm-build dnf -y install dnf-plugins-core rpm-build rpmdevtools
mkdir rpms
- name: Clone repository - name: Fetch .spec file
uses: actions/checkout@v2 run: |
with: mkdir spec
path: osbuild # 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 - name: Install RPM build dependencies
run: dnf -y builddep osbuild/osbuild.spec 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 - name: Build RPMs
run: | run: |
pushd osbuild mkdir rpmbuild rpms build
make rpm rpmbuild -bb \
popd --define "_sourcedir `pwd`/sources" \
cp -av osbuild/output/*/*.rpm rpms/ --define "_specdir `pwd`/spec" \
date > rpms/timestamp.txt --define "_builddir `pwd`/rpmbuild" \
--define "_srcrpmdir `pwd`/srpms" \
--define "_rpmdir `pwd`/rpms" \
--define "_buildrootdir `pwd`/build" \
spec/osbuild.spec
- name: "Upload artifacts" - name: "Upload artifacts"
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v1
with: with:
name: Packages name: rpms
path: rpms/ path: rpms/
- name: Test RPM installation - name: Test RPM installation
run: | run: |
pushd rpms pushd rpms/noarch
dnf -y install $(ls *.rpm) dnf -y install $(ls *.rpm)
popd popd