Replace workflows for CI workflow

This commit is contained in:
Christian Tosta
2025-04-18 13:17:24 -03:00
parent 2a1c30ea74
commit 003a05b17a
3 changed files with 53 additions and 125 deletions

View File

@@ -1,41 +0,0 @@
name: auto-tag
on:
push:
schedule:
- cron: '30 3 * * *'
workflow_dispatch:
jobs:
create-tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install cmake g++ gcc
- name: Set environment
run: |
cmake --fresh -B build -S .
echo "NEW_TAG=v$(cat build/version)" >> $GITHUB_ENV
- name: Check if package version has corresponding git tag
id: tagged
shell: bash
run: |
git show-ref \
--tags --verify --quiet -- \
"refs/tags/${NEW_TAG}" \
&& echo tagged=1 >> $GITHUB_OUTPUT \
|| echo tagged=0 >> $GITHUB_OUTPUT
- name: Create new tag
if: steps.tagged.outputs.tagged == 0
run: |
git tag ${NEW_TAG} \
&& git push origin ${NEW_TAG} \
|| exit 0

View File

@@ -1,84 +0,0 @@
name: build-rpm
on:
workflow_dispatch:
workflow_run:
workflows: [auto-tag]
types: [completed]
push:
#tags:
# - v[0-9]+.[0-9]+.[0-9]+
jobs:
build-upload-rpm:
name: Build and upload RPM packages
runs-on: ubuntu-latest
container:
image: fedora:latest
steps:
- uses: actions/checkout@v4
- name: install RPM build tools
run: |
dnf -y install \
cmake \
gcc \
gcc-c++ \
git \
rpm-build \
rpmdevtools \
tar
- name: Setup RPM build tree
run: |
rpmdev-setuptree
- name: Create source tarball
run: |
cmake --fresh -B build -S .
cmake --build build --target sdist
- name: Set environment variables
run: |
echo "PKG_VERSION=$(cat build/version)" >> $GITHUB_ENV
echo "PKG_NAME=$(grep -Po 'Name:\ *\K[\S ]*' \
packaging/pkg.spec.in)" >> $GITHUB_ENV
- name: Copy SOURCES and SPEC file
run: |
cp packaging/pkg.spec.in ~/rpmbuild/SPECS/${PKG_NAME}.spec
rpmdev-bumpspec -n ${PKG_VERSION} ~/rpmbuild/SPECS/${PKG_NAME}.spec
cp dist/*.src.tar.gz ~/rpmbuild/SOURCES/
- name: Build RPM packages
run: |
dnf -y builddep ~/rpmbuild/SPECS/${PKG_NAME}.spec
rpmbuild -ba ~/rpmbuild/SPECS/${PKG_NAME}.spec
- name: Upload built SRPM/RPM packages
uses: actions/upload-artifact@v4
with:
name: artifact-built-rpms
path: |
~/rpmbuild/RPMS/
~/rpmbuild/SRPMS/
- name: Check if package version has corresponding git tag
id: tagged
shell: bash
run: |
git show-ref \
--tags --verify --quiet -- \
"refs/tags/${NEW_TAG}" \
&& echo tagged=1 >> $GITHUB_OUTPUT \
|| echo tagged=0 >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag' && steps.tagged.output.tagged == 1
with:
generate_release_notes: false
files: |
~/rpmbuild/RPMS/*/*.rpm
~/rpmbuild/SRPMS/*.rpm

53
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,53 @@
name: Build and Release
on:
push:
schedule:
- cron: '30 3 * * *'
workflow_dispatch:
jobs:
release-ci:
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.get_metadata.outputs.VERSION }}
steps:
- name: Local checkout
- uses: actions/checkout@v4
- name: Install CI dependencies
run: |
sudo apt-get update
sudo apt-get -y -qq install cmake g++ gcc
- name: Get latest package metadata
id: get_metadata
run: |
cmake --fresh -B build -S .
echo "TAG=v$(cat build/version)" >> $GITHUB_OUTPUT
echo "VERSION=$(cat build/version)" >> $GITHUB_OUTPUT
- name: Check if package version has corresponding git tag
id: tagged
shell: bash
run: |
git show-ref \
--tags --verify --quiet -- \
"refs/tags/${{ steps.get_metadata.outputs.TAG }}" \
&& echo tagged=1 >> $GITHUB_OUTPUT \
|| echo tagged=0 >> $GITHUB_OUTPUT
- name: Create new tag
if: steps.tagged.outputs.tagged == 0
run: |
git tag ${{ steps.get_metadata.outputs.TAG }} \
&& git push origin ${{ steps.get_metadata.outputs.TAG }} \
|| exit 0
# build-fedora:
# needs: release-ci
# uses: .github/workflows/fedora.yml
# with:
#cache-file-path: ${{ needs.release-ci.outputs.ASSET }}
# version: ${{ needs.release-ci.outputs.VERSION }}
# containers: "['fedora:latest', 'fedora:41']"