build via workflow?

This commit is contained in:
GloriousEggroll 2025-04-13 22:11:15 -06:00
parent 9971bb507e
commit 757645fe51
4 changed files with 158 additions and 1 deletions

View file

@ -0,0 +1,75 @@
name: Flatpost RPM Build - Fedora/Nobara 41
on:
workflow_call:
inputs:
version:
required: false
type: string
shasum:
required: false
type: string
jobs:
build:
runs-on: ubuntu-latest
container:
image: fedora:41
steps:
- name: Install Git
run: dnf install -y git
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git safe directory
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Install build dependencies
run: dnf install -y git make python3-devel python3-build
- name: Extract Version and SHA
run: |
# Get version from git tags (assuming semantic versioning format)
VERSION=$(git describe --tags --abbrev=0 || echo "unknown")
echo $VERSION
# Get current commit SHA
COMMIT_SHA=$(git rev-parse HEAD)
echo $COMMIT_SHA
# Store values in environment file
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_ENV
- name: Build the project
run: |
# Use either provided input or extracted value
git submodule update --init --recursive
cd ..
mkdir -p ~/rpmbuild/SOURCES/
cp -R flatpost flatpost-${{ env.VERSION }}/
tar -cvzf flatpost-${{ env.VERSION }}.tar.gz flatpost-${{ env.VERSION }}
mv flatpost-${{ env.VERSION }}.tar.gz ~/rpmbuild/SOURCES/
rm -Rf flatpost-${{ env.VERSION }}/
cd flatpost/
sed -i "s|^%global tag .*|%global tag ${{ env.VERSION }}|g" packaging/rpm/flatpost.spec
cat packaging/rpm/flatpost.spec | grep tag
sed -i "s|^%global commit .*|%global commit ${{ env.COMMIT_SHA }}|g" packaging/rpm/flatpost.spec
cat packaging/rpm/flatpost.spec | grep commit
rpmbuild -ba packaging/rpm/flatpost.spec
mv ~/rpmbuild/RPMS/x86_64/flatpost-${{ env.VERSION }}*.rpm \
~/rpmbuild/RPMS/x86_64/flatpost-${{ env.VERSION }}.fc41.rpm
- name: Fedora-40
uses: actions/upload-artifact@v4
with:
name: flatpost-${{ env.VERSION }}.fc41.rpm
path: ~/rpmbuild/RPMS/x86_64/flatpost-${{ env.VERSION }}.fc41.rpm

View file

@ -0,0 +1,48 @@
name: Flatpost Release
on:
workflow_call:
inputs:
version:
required: true
type: string
file1:
required: true
type: string
name1:
required: true
type: string
name2:
type: string
default: ""
file2:
type: string
default: ""
jobs:
release:
name: Publish
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: ${{ inputs.name1 }}
file: ${{ inputs.file1 }}
- name: ${{ inputs.name2 }}
file: ${{ inputs.file2 }}
steps:
- name: Download ${{ matrix.name }} from artifact
uses: actions/download-artifact@v4
if: ${{ matrix.name != '' }}
with:
name: ${{ matrix.name }}
- name: Upload ${{ matrix.name }} to release
uses: svenstaro/upload-release-action@v2
if: ${{ matrix.name != '' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ matrix.file }}
asset_name: ${{ matrix.name }}
tag: ${{ inputs.version }}
overwrite: true

23
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,23 @@
iname: Build and upload release
on:
release:
types: [published]
jobs:
fedora41-build:
name: Fedora 41 Build
uses: ./.github/workflows/build-flatpost-fedora-41.yml
with:
version: ${{ github.ref_name }}
shasum: ${{ github.sha }}
fedora41-release:
name: Fedora 41 Release ${{ github.ref_name }}
needs: fedora41-build
uses: ./.github/workflows/build-umu-publish-release.yml
with:
version: ${{ github.ref_name }}
file1: flatpost-${{ github.ref_name }}.fc41.rpm
name1: flatpost-${{ github.ref_name }}.fc41.rpm
file1: flatpost-${{ github.ref_name }}.fc41.src.rpm
name1: flatpost-${{ github.ref_name }}.fc41.src.rpm