Skip to content

Commit

Permalink
Improve Github Actions for Ubuntu and Fedora release packaging
Browse files Browse the repository at this point in the history
* Build release packages for both Ubuntu-20.04 and Ubuntu-22.04. Both
  are LTS releases and release packages for both will be needed by other
  projects.
* Set CPACK_DEBIAN_PACKAGE_RELEASE during CMake packaging in the Github
  Actions workflow to append the intended Ubuntu release to the package
  version
* Enable CPACK_RPM_PACKAGE_RELEASE_DIST for RPM packaging in
  CMakeLists.txt such that %{?dist} is appended to the Release tag in
  the spec file to indicate the build environment distribution
* Let artifact upload fail (instead of warn) if no packages are found
  • Loading branch information
leonlynch committed Aug 10, 2022
1 parent 2dab7d6 commit 873d298
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/fedora-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,6 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: tr31-${{env.GIT_DESCRIBE}}-fedora
name: tr31-${{ env.GIT_DESCRIBE }}-fedora36
path: build/tr31-*.rpm
if-no-files-found: error
26 changes: 18 additions & 8 deletions .github/workflows/ubuntu-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ jobs:
- name: Test
run: cmake --build build --target test

build-ubuntu-2004-release:
name: Ubuntu 20.04 build (release)
runs-on: ubuntu-20.04
build-ubuntu-release:
strategy:
fail-fast: false
matrix:
include:
- { name: "Ubuntu 20.04", os: ubuntu-20.04, ubuntu_release_name: "focal" }
- { name: "Ubuntu 22.04", os: ubuntu-22.04, ubuntu_release_name: "jammy" }

name: ${{ matrix.name }} build (release)
runs-on: ${{ matrix.os }}

steps:
- name: Install dependencies
Expand All @@ -59,12 +66,14 @@ jobs:
submodules: recursive

- name: Get version from git tag
run: |
git describe --always --dirty
echo "GIT_DESCRIBE=$(git describe --always --dirty)" >> $GITHUB_ENV
run: echo "GIT_DESCRIBE=$(git describe --always --dirty)" >> $GITHUB_ENV

- name: Configure CMake
run: cmake -B build -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=YES -DBUILD_DOCS=YES -DCPACK_COMPONENTS_GROUPING=ALL_COMPONENTS_IN_ONE
# CPACK_DEBIAN_PACKAGE_RELEASE augments the package version for the
# intended Ubuntu release. The ppa1 component indicates that this is not
# an official Ubuntu package. The release name component indicates that
# this is for the specific Ubuntu release that has that name.
run: cmake -B build -DCMAKE_BUILD_TYPE="RelWithDebInfo" -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=YES -DBUILD_DOCS=YES -DCPACK_COMPONENTS_GROUPING=ALL_COMPONENTS_IN_ONE -DCPACK_DEBIAN_PACKAGE_RELEASE="0ubuntu1~ppa1~${{ matrix.ubuntu_release_name }}1"

- name: Build
run: cmake --build build
Expand All @@ -78,5 +87,6 @@ jobs:
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: tr31-${{env.GIT_DESCRIBE}}-ubuntu
name: tr31-${{ env.GIT_DESCRIBE }}-${{ matrix.os }}
path: build/tr31_*.deb
if-no-files-found: error
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ if(rpmbuild_FOUND)
set(CPACK_RPM_COMPONENT_INSTALL ON)
# use default rpm package naming
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)
# configure license and changelog
set(CPACK_RPM_PACKAGE_LICENSE "LGPLv2+")
set(CPACK_RPM_CHANGELOG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/rpm_changelog.txt")
Expand Down

0 comments on commit 873d298

Please sign in to comment.