Skip to content

Commit

Permalink
Add rpm build step to the PR check
Browse files Browse the repository at this point in the history
Github workflow allow us to build rpm artefact and that
helps with testing.

Current spec file is replaced by adjusted Fedora spec.

Running rpm build in Fedora container has some issues
with git therefore here is one extra step to create tar
artefact to workaround this obstacle.
  • Loading branch information
thalman committed Aug 19, 2024
1 parent cef8c0b commit 509c792
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 31 deletions.
67 changes: 66 additions & 1 deletion .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,74 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python environment
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Run flake8
uses: py-actions/flake8@v2
with:
max-line-length: "100"
path: "."

create-archive:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create archive
run: |
set -x
APP_VERSION=`grep -i '^version:' rpm/keycloak-httpd-client-install.spec | sed 's/.* //g'`
echo "APP_VERSION=$APP_VERSION" >> "$GITHUB_ENV"
git archive --format=tar.gz --prefix=keycloak-httpd-client-install-$APP_VERSION/ HEAD >keycloak-httpd-client-install-$APP_VERSION.tar.gz
echo "APP_VERSION=$APP_VERSION" >> "$GITHUB_ENV"
- name: Upload tar archive
uses: actions/upload-artifact@v4
with:
name: tar
path: keycloak-httpd-client-install-*.tar.gz
retention-days: 30

build-fedora-rpm:
runs-on: ubuntu-latest
container: fedora:latest
needs: create-archive
steps:
- name: Download tar
uses: actions/download-artifact@v4
with:
name: tar
- name: Build rpm
run: |
set -x
dnf -y install rpm-build python3-devel python3-setuptools
rpmbuild -D "release_string $GITHUB_SHA" -D "_rpmdir $(pwd)/rpmbuild" -ta keycloak-httpd-client-install-*.tar.gz
find ./rpmbuild -name '*.rpm' -exec mv {} ./ \;
- name: Upload rpms
uses: actions/upload-artifact@v4
with:
name: fedora-rpms
path: "*.rpm"
retention-days: 30

build-el-rpm:
runs-on: ubuntu-latest
container: rockylinux:9
needs: create-archive
steps:
- name: Download tar
uses: actions/download-artifact@v4
with:
name: tar
- name: Build rpm
run: |
set -x
dnf -y install rpm-build python3-devel python3-setuptools
rpmbuild -D "release_string $GITHUB_SHA" -D "_rpmdir $(pwd)/rpmbuild" -ta keycloak-httpd-client-install-*.tar.gz
find ./rpmbuild -name '*.rpm' -exec mv {} ./ \;
- name: Upload rpms
uses: actions/upload-artifact@v4
with:
name: el-rpms
path: "*.rpm"
retention-days: 30
75 changes: 45 additions & 30 deletions rpm/keycloak-httpd-client-install.spec
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
%global srcname keycloak-httpd-client-install
%global summary Tools to configure Apache HTTPD as Keycloak client

%if 0%{?fedora}
%global with_python3 1
%if (0%{?fedora} > 0 && 0%{?fedora} < 30) || (0%{?rhel} > 0 && 0%{?rhel} <= 7)
%bcond_without python2
%bcond_without python3
%endif

%if 0%{?fedora} >= 30 || 0%{?rhel} >= 8
%bcond_with python2
%bcond_without python3
%endif

Name: %{srcname}
Version: 0.4
Release: 1%{?dist}
Version: 1.2
Release: %{?release_string}%{!?release_string: 1}%{?dist}
Summary: %{summary}

%global git_tag RELEASE_%(r=%{version}; echo $r | tr '.' '_')

License: GPLv3
URL: https://github.com/jdennis/keycloak-httpd-client-install
Source0: https://github.com/jdennis/keycloak-httpd-client-install/archive/%{git_tag}.tar.gz#/%{srcname}-%{version}.tar.gz

License: GPL-3.0-or-later
URL: https://github.com/lachset/keycloak-httpd-client-install
Source0: https://github.com/lachset/keycloak-httpd-client-install/releases/download/%{version}/keycloak-httpd-client-install-%{version}.tar.gz
BuildArch: noarch

%if %{with python2}
BuildRequires: python2-devel
%endif
# ^^^ with_python2

%if 0%{?with_python3}
BuildRequires: python3-devel
BuildRequires: (python3-setuptools if python3-devel >= 3.12)
%endif

Requires: %{_bindir}/keycloak-httpd-client-install
Expand All @@ -33,21 +42,24 @@ libraries and tools which can automate and simplify configuring an
Apache HTTPD authentication module and registering as a client of a
Keycloak IdP.

%if %{with python2}
%package -n python2-%{srcname}
Summary: %{summary}

%{?python_provide:%python_provide python2-%{srcname}}

Requires: %{name} = %{version}-%{release}
Requires: python-requests
Requires: python-requests-oauthlib
Requires: python-jinja2
Requires: python2-requests
Requires: python2-requests-oauthlib
Requires: python2-jinja2
Requires: %{_bindir}/keycloak-httpd-client-install

%description -n python2-%{srcname}
Keycloak is an authentication server. This package contains libraries and
programs which can invoke the Keycloak REST API and configure clients
of a Keycloak server.
%endif
# ^^^ with_python2

%if 0%{?with_python3}
%package -n python3-%{srcname}
Expand All @@ -59,6 +71,7 @@ Requires: %{name} = %{version}-%{release}
Requires: python3-requests
Requires: python3-requests-oauthlib
Requires: python3-jinja2
Requires: python3-lxml

%description -n python3-%{srcname}
Keycloak is an authentication server. This package contains libraries and
Expand All @@ -68,25 +81,36 @@ of a Keycloak server.
%endif

%prep
%autosetup -n %{srcname}-%{version}
%autosetup -n %{srcname}-%{version} -p1

%build
%if %{with python2}
%py2_build
%endif
# ^^^ with_python2

%if 0%{?with_python3}
%py3_build
%endif

%install
%if %{with python2}
# Must do the python2 install first because the scripts in /usr/bin are
# overwritten with every setup.py install, and in general we want the
# python3 version to be the default.
%py2_install
%endif
# ^^^ with_python2

%if 0%{?with_python3}
# py3_install won't overwrite files if they have a timestamp greater-than
# or equal to the py2 installed files. If both the py2 and py3 builds execute
# quickly the files end up with the same timestamps thus leaving the py2
# version in the py3 install. Therefore remove any files susceptible to this.
%if %{with python2}
rm %{buildroot}%{_bindir}/keycloak-httpd-client-install
%endif
# ^^^ with_python2
%py3_install
%endif

Expand All @@ -98,37 +122,28 @@ install -c -m 644 doc/keycloak-httpd-client-install.8 %{buildroot}/%{_mandir}/ma
%doc README.md doc/ChangeLog
%{_datadir}/%{srcname}/

%if %{with python2}
# Note that there is no %%files section for the unversioned python module if we are building for several python runtimes
%files -n python2-%{srcname}
%{python2_sitelib}/*

%if ! 0%{?with_python3}
%{_bindir}/keycloak-httpd-client-install
%{_bindir}/keycloak-rest
%{_mandir}/man8/*
%endif
%endif
# ^^^ with_python2

%if 0%{?with_python3}
%files -n python3-%{srcname}
%{python3_sitelib}/*
%{_bindir}/keycloak-httpd-client-install
%{_bindir}/keycloak-rest
%{_mandir}/man8/*
%endif

%changelog
* Wed Jun 8 2016 John Dennis <jdennis@redhat.com> - 0.4-1
- new upstream
- add methods to add/remove client redirect URI
- add function to parse SP metadata to extract AssertionConsumerServiceURL's
- Add all AssertionConsumerServiceURL's as redirect URI's during
client registration.

* Fri May 20 2016 John Dennis <jdennis@redhat.com> - 0.3-1
- new upstream
See ChangeLog for details

* Tue May 17 2016 John Dennis <jdennis@redhat.com> - 0.2-1
- new upstream
- Add keycloak-httpd-client-install.8 man page

* Fri May 13 2016 John Dennis <jdennis@redhat.com> - 0.1-1
- Initial version
* Mon Aug 19 2024 Tomas Halman <tomas@halman.net> - 1.2-1
Repository cleanup, preparing for new version
Spec file is adopted from Fedora.

0 comments on commit 509c792

Please sign in to comment.