Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 50 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,45 @@ concurrency:
cancel-in-progress: true

jobs:
tarball:
name: Tarball

runs-on: ubuntu-latest

steps:
- name: Get source code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install build requirements
run: python -m pip install build

- name: Create distributions
run: python -m build . --sdist --wheel --outdir .

- uses: actions/upload-artifact@v4
with:
name: tarball
path: htgettoken-*.tar.*
if-no-files-found: error

- uses: actions/upload-artifact@v4
with:
name: wheel
path: htgettoken*.whl
if-no-files-found: error

# -- RPM builds --

# Build the Source RPM
rhel-srpm:
name: EL ${{ matrix.version }} (${{ matrix.distro }}) source package
needs:
- tarball
strategy:
fail-fast: false
matrix:
Expand All @@ -36,29 +70,23 @@ jobs:
version: 9
runs-on: ubuntu-latest
container: ${{ matrix.distro }}:${{ matrix.version }}
env:
TARBALL: "htgettoken-*.tar.*"
steps:
- name: Get source code
uses: actions/checkout@v3
- name: Download tarball
uses: actions/download-artifact@v4
with:
name: tarball

- name: Configure SRPM build tools
run: |
yum -y install \
make \
python-srpm-macros \
dnf -y install \
"*-srpm-macros" \
rpm-build \
yum-utils \
;

- name: Create distributions
run: make sources

- name: Create source package
run: |
rpmbuild \
--define "_sourcedir $(pwd)" \
--define "_srcrpmdir $(pwd)" \
-bs \
htgettoken.spec
run: rpmbuild -ts --define "_srcrpmdir $(pwd)" ${TARBALL}

- uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -96,24 +124,20 @@ jobs:
dnf config-manager --set-enabled crb

- name: Configure EPEL
run: yum -y install epel-release
run: dnf -y install epel-release

- name: Install build tools
run: |
yum -y -q install \
dnf -y -q install \
rpm-build \
yum-utils \
"dnf-command(builddep)" \
;

- name: Install epel-rpm-macros
if: matrix.version < 9
run: yum -y -q install epel-rpm-macros

- name: Install build dependencies
run: yum-builddep -y htgettoken-*.src.rpm
run: dnf builddep -y htgettoken-*.src.rpm

- name: List installed packages
run: yum list installed
run: dnf list installed

- name: Build binary packages
run: |
Expand Down Expand Up @@ -164,10 +188,10 @@ jobs:
name: rpm-${{ matrix.distro }}-${{ matrix.version }}

- name: Configure EPEL
run: yum -y install epel-release
run: dnf -y install epel-release

- name: Install RPMs
run: yum -y install *.rpm
run: dnf -y install *.rpm

- name: Test htgettoken
run: /usr/bin/htgettoken --help
35 changes: 15 additions & 20 deletions htgettoken.spec
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@ Prefix: %{_prefix}
# https://codeload.github.com/fermitools/htgettoken/tar.gz/%%{version}
Source0: %{name}-%{version}.tar.gz

# rpmbuild dependencies
BuildRequires: python-rpm-macros
BuildRequires: python3-rpm-macros

# build dependencies
BuildRequires: python3
BuildRequires: python%{python3_pkgversion}-pip
BuildRequires: python%{python3_pkgversion}-setuptools
BuildRequires: python%{python3_pkgversion}-wheel
BuildRequires: python3-devel
BuildRequires: python3dist(pip)
BuildRequires: python3dist(setuptools)
BuildRequires: python3dist(wheel)

# -- Package: htgettoken

# /usr/bin/htgettoken:
Requires: python%{python3_pkgversion}-gssapi
Requires: python%{python3_pkgversion}-paramiko
Requires: python%{python3_pkgversion}-urllib3
# For RHEL>=9 all requirements automatically provided by Python metadata
%if 0%{?rhel} && 0%{?rhel} < 9
Requires: python3dist(gssapi)
Requires: python3dist(paramiko)
Requires: python3dist(urllib3)
%endif
# /usr/bin/httokendecode:
Requires: jq
Recommends: scitokens-cpp
Expand All @@ -50,19 +49,11 @@ htgettoken gets OIDC bearer tokens by interacting with Hashicorp vault
%autosetup -n %{name}-%{version}

%build
%if 0%{?rhel} >= 9
%py3_build_wheel
%else
%py3_build
%endif

%install
# install the Python project
%if 0%{?rhel} >= 9
%py3_install_wheel %{name}-%{version}-*.whl
%else
%py3_install
%endif
# link httokendecode to htdecodetoken
(cd %{buildroot}%{_bindir}/; ln -s htdecodetoken httokendecode)
# install man pages
Expand All @@ -71,7 +62,7 @@ gzip -c %{name}.1 >%{buildroot}%{_datadir}/man/man1/%{name}.1.gz
for f in %{name} htdestroytoken htdecodetoken httokensh; do
gzip -c $f.1 >%{buildroot}%{_datadir}/man/man1/$f.1.gz
done
ln -s htdecodetoken.1 %{buildroot}%{_datadir}/man/man1/httokendecode.1.gz
ln -s htdecodetoken.1 %{buildroot}%{_datadir}/man/man1/httokendecode.1.gz

%clean
rm -rf $RPM_BUILD_ROOT
Expand All @@ -80,6 +71,10 @@ rm -rf $RPM_BUILD_ROOT


%changelog
# - Add BuildRequires python3-devel to generate correct Python metadata.
# - Remove explicit Requires for python dependencies, rely on Python metadata.
# - Always build with wheels.

* Tue Feb 25 2025 Dave Dykstra <dwd@fnal.gov> 2.1-1
- Fix htdecodetoken to work with token files that do not end in a newline.
- Support args in htgettoken.main() Python entry point.
Expand Down
Loading