Build rpm package on release #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build rpm package on release | |
on: | |
release: | |
types: [published] | |
jobs: | |
build-rpm: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install RPM build tools | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y rpm rpm2cpio build-essential | |
- name: Checkout source | |
uses: actions/checkout@v3 | |
- name: Set version and app name | |
run: | | |
APP_NAME=libbash.sh | |
# get release version without the "v" | |
VERSION="$(echo ${GITHUB_REF##*/} | sed 's/^v//')" | |
INSTALL_DIR=usr/lib/$APP_NAME | |
echo "APP_NAME=$APP_NAME" >> $GITHUB_ENV | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Set up RPM build structure | |
run: | | |
mkdir -p rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS,tmp} | |
tar -czf rpm/SOURCES/${APP_NAME}-${VERSION}.tar.gz --transform "s/^./${APP_NAME}-${VERSION}/" \ | |
$(find . -maxdepth 1 -mindepth 1 ! -name ".git*" ! -name "rpm" ! -name "examples" ! -name "tests") | |
- name: Create SPEC file | |
run: | | |
cat > rpm/SPECS/${APP_NAME}.spec <<EOF | |
Name: ${APP_NAME} | |
Version: ${VERSION} | |
Release: 1%{?dist} | |
Summary: MyApp RPM package | |
License: MIT | |
URL: https://github.com/${{ github.repository }} | |
Source0: %{name}-%{version}.tar.gz | |
BuildArch: noarch | |
BuildRoot: %{_tmppath}/%{name}-%{version}-build | |
%description | |
Library of useful Bash functions. | |
%prep | |
%setup -q | |
%build | |
%install | |
mkdir -p %{buildroot}/usr/lib/%{name} | |
cp -a * %{buildroot}/usr/lib/%{name} | |
%files | |
/usr/lib/%{name} | |
%changelog | |
* $(date +"%a %b %d %Y") Jean Prunneaux <jean@prunneaux.com> - ${VERSION}-1 | |
- Initial RPM release | |
EOF | |
- name: Build RPM | |
run: | | |
rpmbuild --define "_topdir $PWD/rpm" -ba rpm/SPECS/${APP_NAME}.spec | |
- name: Upload RPM to release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
rpm/RPMS/noarch/${{ env.APP_NAME }}-${{ env.VERSION }}-1.noarch.rpm | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |