Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

Commit

Permalink
fix: rework rpm build workflow to use centos
Browse files Browse the repository at this point in the history
  • Loading branch information
madebyjake committed Dec 20, 2024
1 parent e0ca5bc commit a9aaf25
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 71 deletions.
55 changes: 19 additions & 36 deletions .github/workflows/build_release_rpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,30 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v2

- name: Set up build environment
run: |
sudo apt-get update
sudo apt-get install -y rpm rpm2cpio python3-dev python3-pip make
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
- name: Install Python Dependencies
run: |
pip install --upgrade pip
# pip install -r requirements.txt if needed
- name: Run Python tests
run: python -m unittest discover

- name: Determine Version
- name: Determine version
id: determine_version
run: |
# Extract version from branch name: release-1.1.x -> 1.1.x
VERSION="${GITHUB_REF#refs/heads/release-}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create source tarball
run: |
tar czvf ~/rpmbuild/SOURCES/md5sift-${VERSION}.tar.gz \
--transform "s,^,md5sift-${VERSION}/," \
-C $GITHUB_WORKSPACE .
- name: Copy spec file
run: cp $GITHUB_WORKSPACE/md5sift.spec ~/rpmbuild/SPECS/

- name: Update spec version
run: |
sed -i "s/^Version:.*/Version: ${VERSION}/" ~/rpmbuild/SPECS/md5sift.spec
- name: Build RPM
run: rpmbuild -ba ~/rpmbuild/SPECS/md5sift.spec

- name: Test RPM Installation
- name: Build in CentOS Container
run: |
sudo rpm -ivh ~/rpmbuild/RPMS/noarch/md5sift-${VERSION}-1.noarch.rpm
md5sift --help
docker run --rm -v ${{ github.workspace }}:/src -w /src centos:8 /bin/bash -c "
yum install -y rpm-build python3 python3-pip make &&
mkdir -p /src/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} &&
pip3 install --upgrade pip &&
python3 -m unittest discover &&
# Update spec file version
sed -i 's/^Version:.*/Version: ${VERSION}/' md5sift.spec &&
# Create source tarball
tar czvf /src/rpmbuild/SOURCES/md5sift-${VERSION}.tar.gz md5sift.py LICENSE README.md &&
cp md5sift.spec /src/rpmbuild/SPECS/ &&
# Build the RPM
rpmbuild -ba /src/rpmbuild/SPECS/md5sift.spec --define '_topdir /src/rpmbuild' &&
# Test the RPM installation
rpm -ivh --nodeps /src/rpmbuild/RPMS/noarch/md5sift-${VERSION}-1.noarch.rpm &&
md5sift --help
"
- name: Create GitHub Release
id: create_release
Expand All @@ -72,6 +55,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ~/rpmbuild/RPMS/noarch/*.rpm
asset_path: rpmbuild/RPMS/noarch/*.rpm
asset_name: md5sift-${{ env.VERSION }}-1.noarch.rpm
asset_content_type: application/x-rpm
54 changes: 20 additions & 34 deletions .github/workflows/build_test_rpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,27 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v2

- name: Set up build environment
- name: Build and Test in CentOS Container
run: |
sudo apt-get update
sudo apt-get install -y rpm rpm2cpio python3-dev python3-pip make
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
- name: Install Python Dependencies
run: |
pip install --upgrade pip
# If you have Python dependencies, install them here
# pip install -r requirements.txt
- name: Run Python tests
run: python -m unittest discover

- name: Create source tarball
run: |
VERSION=1.1.0
tar czvf ~/rpmbuild/SOURCES/md5sift-${VERSION}.tar.gz \
--transform "s,^,md5sift-${VERSION}/," \
-C $GITHUB_WORKSPACE .
- name: Copy spec file
run: cp $GITHUB_WORKSPACE/md5sift.spec ~/rpmbuild/SPECS/

- name: Build RPM
run: rpmbuild -ba ~/rpmbuild/SPECS/md5sift.spec

- name: Test RPM Installation
run: |
sudo rpm -ivh ~/rpmbuild/RPMS/noarch/md5sift-1.1.0-1.noarch.rpm
md5sift --help
- name: Store RPM as artifact
docker run --rm -v ${{ github.workspace }}:/src -w /src centos:8 /bin/bash -c "
yum install -y rpm-build python3 python3-pip make &&
mkdir -p /src/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} &&
pip3 install --upgrade pip &&
# Run tests before building
python3 -m unittest discover &&
# Create source tarball
tar czvf /src/rpmbuild/SOURCES/md5sift-1.1.0.tar.gz md5sift.py LICENSE README.md &&
# Copy spec file
cp md5sift.spec /src/rpmbuild/SPECS/ &&
# Build the RPM
rpmbuild -ba /src/rpmbuild/SPECS/md5sift.spec --define '_topdir /src/rpmbuild' &&
# Test the RPM installation inside container
rpm -ivh --nodeps /src/rpmbuild/RPMS/noarch/md5sift-1.1.0-1.noarch.rpm &&
md5sift --help
"
- name: Upload RPM artifact
uses: actions/upload-artifact@v2
with:
name: md5sift-rpm
path: ~/rpmbuild/RPMS/noarch/*.rpm
path: rpmbuild/RPMS/noarch/*.rpm
1 change: 0 additions & 1 deletion md5sift.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Source0: %{name}-%{version}.tar.gz

BuildArch: noarch
Requires: python3
%define __requires_exclude ^/usr/bin/env.*

%description
md5sift generates MD5 checksum reports for files within a local directory or network share.
Expand Down

0 comments on commit a9aaf25

Please # to comment.