From 757645fe518a655234f9325a4cbc7c9389866b63 Mon Sep 17 00:00:00 2001 From: GloriousEggroll Date: Sun, 13 Apr 2025 22:11:15 -0600 Subject: [PATCH] build via workflow? --- .github/workflows/build-flatpost-f41.yml | 75 +++++++++++++++++++ .../build-flatpost-publish-release.yml | 48 ++++++++++++ .github/workflows/release.yml | 23 ++++++ packaging/{ => rpm}/flatpost.spec | 13 +++- 4 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-flatpost-f41.yml create mode 100644 .github/workflows/build-flatpost-publish-release.yml create mode 100644 .github/workflows/release.yml rename packaging/{ => rpm}/flatpost.spec (85%) diff --git a/.github/workflows/build-flatpost-f41.yml b/.github/workflows/build-flatpost-f41.yml new file mode 100644 index 0000000..5e0403a --- /dev/null +++ b/.github/workflows/build-flatpost-f41.yml @@ -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 diff --git a/.github/workflows/build-flatpost-publish-release.yml b/.github/workflows/build-flatpost-publish-release.yml new file mode 100644 index 0000000..3905089 --- /dev/null +++ b/.github/workflows/build-flatpost-publish-release.yml @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..40bc9e8 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/packaging/flatpost.spec b/packaging/rpm/flatpost.spec similarity index 85% rename from packaging/flatpost.spec rename to packaging/rpm/flatpost.spec index 9c49a0c..1f97cad 100644 --- a/packaging/flatpost.spec +++ b/packaging/rpm/flatpost.spec @@ -1,6 +1,17 @@ +%global tag 1.0.0 + +# Manual commit is auto-inserted by workflow +%global commit 35fa9a68d94bde4ed68a6bd07482b2a87a8d42df + +%global shortcommit %(c=%{commit}; echo ${c:0:7}) + +%global build_timestamp %(date +"%Y%m%d") + +%global rel_build 1.%{build_timestamp}.%{shortcommit}%{?dist} + Name: flatpost Version: 1.0.0 -Release: 1%{?dist} +Release: %{rel_build} License: BSD 2-Clause Summary: Desktop environment agnostic Flathub software center.