Skip to content

Commit

Permalink
Merge pull request #4 from brianhlin/INF-794.build-and-upload-rpms
Browse files Browse the repository at this point in the history
Fix build and upload of RPM to release tag (INF-794)
  • Loading branch information
brianhlin authored Aug 8, 2023
2 parents bcd48f0 + 5997a8e commit 7a47188
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
40 changes: 32 additions & 8 deletions .github/workflows/pamoauthrpmbuild.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Build RPMS on release

on:
Expand All @@ -6,23 +7,46 @@ on:

jobs:
Build-RPMS:
strategy:
fail-fast: false
matrix:
os_base:
- "docker.io/centos:centos7"
- "quay.io/almalinux/almalinux:8"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Get git tag
id: get-git-tag
run: |
echo "tag_name=${GITHUB_REF##refs/tags/}" >> $GITHUB_OUTPUT
- name: Set up build directory
run: |
mkdir -p ${{github.workspace}}/build_output
sudo chown 1000:1000 ${{github.workspace}}/build_output
- name: Build RPMS
- name: Build RPMs
env:
IMAGE_BASE: ${{ matrix.os_base }}
GIT_TAG: ${{ steps.get-git-tag.outputs.tag_name }}
run: |
URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/archive/${GIT_TAG}.tar.gz
cd ./packaging/rpm
docker build -t pamoauth2device-rpm-build .
docker run --rm -v ${{github.workspace}}/build_output:/data pamoauth2device-rpm-build:latest cp -r rpmbuild/RPMS /data
- name: Upload RPMS
uses: actions/upload-artifact@v3
docker build --build-arg IMAGE_BASE=$IMAGE_BASE \
--build-arg TARBALL_URL=$URL \
-t pamoauth2device-rpm-build .
docker run --rm \
-v ${{github.workspace}}/build_output:/data \
pamoauth2device-rpm-build:latest \
cp -r rpmbuild/RPMS rpmbuild/SRPMS /data
- name: Upload Release Artifacts
uses: softprops/action-gh-release@v1
with:
name: PAM OAuth2 RPMS
path: build_output/RPMS
files: |
${{ github.workspace}}/build_output/RPMS/x86_64/*
${{ github.workspace}}/build_output/SRPMS/*
tag_name: ${{ steps.get-git-tag.outputs.tag_name }}

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CXXFLAGS=-Wall -fPIC -std=c++11
CXXFLAGS=-Wall -fPIC -std=c++11 -g

LDLIBS=-lpam -lcurl -lldap -llber

Expand Down
14 changes: 9 additions & 5 deletions packaging/rpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
FROM centos:7
# Default to EL8 builds
ARG IMAGE_BASE=quay.io/almalinux/almalinux:8

FROM $IMAGE_BASE

# "ARG IMAGE_BASE" needs to be here again because the previous instance has gone out of scope.
ARG IMAGE_BASE=quay.io/almalinux/almalinux:8
ARG TARBALL_URL=https://github.com/CHTC/pam_oauth2_device/archive/v0.1.3.chtc.tar.gz

RUN yum install -y \
gcc \
Expand All @@ -15,14 +22,11 @@ RUN groupadd builder \

USER builder

# This version must be identical to the version in pamoauth2device.spec
ENV PACKAGE_VERSION=0.1.3.chtc

WORKDIR /home/builder

RUN mkdir -p rpmbuild/SOURCES \
&& cd rpmbuild/SOURCES \
&& curl -L -O https://github.com/stfc/pam_oauth2_device/archive/v${PACKAGE_VERSION}.tar.gz
&& curl -L -O $TARBALL_URL

COPY pamoauth2device.spec .

Expand Down

0 comments on commit 7a47188

Please sign in to comment.