First commit #1
This file contains 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 and Release RPMs | ||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: [ main ] | ||
workflow_dispatch: | ||
inputs: | ||
full_build: | ||
description: 'Run full build and tests' | ||
required: false | ||
default: false | ||
type: boolean | ||
jobs: | ||
build-rpms: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: rockylinux/rockylinux:9.4 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
# Quick validation for PRs to save minutes | ||
- name: Quick spec validation | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y rpm rpmlint | ||
rpmlint *.spec | ||
# Full build only on tags, manual trigger with full_build, or main branch | ||
- name: Full RPM Build | ||
if: | | ||
startsWith(github.ref, 'refs/tags/') || | ||
(github.event_name == 'workflow_dispatch' && inputs.full_build) || | ||
github.ref == 'refs/heads/main' | ||
run: | | ||
dnf -u update | ||
dnf -y install gcc-fortran make cmake automake gcc-c++ libstdc++-devel | ||
dnf -y install rpm-build rpmdevtools | ||
dnf -y install libev-devel gsl-devel libjpeg-turbo-devel fftw-devel cfitsio-devel | ||
dnf -y install https://www.rpmfind.net/linux/fedora/linux/releases/39/Everything/x86_64/os/Packages/l/libnova-0.15.0-22.fc39.x86_64.rpm | ||
dnf -y install https://www.rpmfind.net/linux/fedora/linux/releases/39/Everything/x86_64/os/Packages/l/libnova-devel-0.15.0-22.fc39.x86_64.rpm | ||
rpmdev-setuptree | ||
cp *.spec ~/rpmbuild/SPECS/ | ||
for spec in ~/rpmbuild/SPECS/*.spec; do | ||
spectool -g -R "$spec" | ||
rpmbuild -ba "$spec" | ||
done | ||
- name: Create Release | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
~/rpmbuild/RPMS/*/*.rpm | ||
~/rpmbuild/SRPMS/*.rpm | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# Upload artifacts only for full builds | ||
- name: Upload RPMs as artifacts | ||
if: | | ||
startsWith(github.ref, 'refs/tags/') || | ||
(github.event_name == 'workflow_dispatch' && inputs.full_build) || | ||
github.ref == 'refs/heads/main' | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: rpms | ||
path: | | ||
~/rpmbuild/RPMS/*/*.rpm | ||
~/rpmbuild/SRPMS/*.rpm | ||
retention-days: 5 # Reduce storage usage by keeping artifacts for less time | ||