From 1d90238b015223b42c7d0fedefe98737af68da10 Mon Sep 17 00:00:00 2001 From: rob thijssen Date: Thu, 16 Apr 2026 15:23:45 +0300 Subject: [PATCH] ci: migrate rpm changelog generation to reusable action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the local .gitea/scripts/generate-rpm-changelog.sh with the shared composite action at https://git.lair.cafe/actions/rpm-changelog@v1. Behaviour is identical — collect commits since the previous v* tag, filter bump-version and merge noise, prepend a dated entry to the spec — but the logic now lives in one place that other projects can consume. Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitea/scripts/generate-rpm-changelog.sh | 65 ------------------------ .gitea/workflows/ci.yml | 10 +++- 2 files changed, 8 insertions(+), 67 deletions(-) delete mode 100755 .gitea/scripts/generate-rpm-changelog.sh diff --git a/.gitea/scripts/generate-rpm-changelog.sh b/.gitea/scripts/generate-rpm-changelog.sh deleted file mode 100755 index 5ee593c..0000000 --- a/.gitea/scripts/generate-rpm-changelog.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# Generate an rpm %changelog entry for this release and prepend it to -# the spec's existing %changelog section. -# -# Usage: generate-rpm-changelog.sh -# -# Collects commits since the previous v* tag, drops the bump-version -# chore commits generated by CI, and writes a dated entry attributed -# to $CHANGELOG_AUTHOR (defaults to the gitea-actions bot identity). - -set -euo pipefail - -SPEC="$1" -VERSION="$2" -AUTHOR="${CHANGELOG_AUTHOR:-Gitea Actions }" - -if [ ! -f "$SPEC" ]; then - echo "error: spec file not found: $SPEC" >&2 - exit 1 -fi - -# Find the previous release tag (exclude the current tag at HEAD). -PREV_TAG=$(git describe --tags --abbrev=0 --match='v*' HEAD^ 2>/dev/null || echo "") - -if [ -n "$PREV_TAG" ]; then - RANGE="${PREV_TAG}..HEAD" - LOG=$(git log --no-merges --pretty=format:'- %s' "$RANGE" \ - | grep -v '^- chore: bump version' \ - | grep -v '^- Merge ' \ - || true) -else - LOG="" -fi - -if [ -z "$LOG" ]; then - LOG="- No user-visible changes" -fi - -DATE=$(LC_ALL=C date -u +'%a %b %d %Y') -ENTRY="* ${DATE} ${AUTHOR} - ${VERSION}-1 -${LOG} -" - -# Prepend the entry to the %changelog section. -TMP=$(mktemp) -awk -v entry="$ENTRY" ' - inserted == 0 && /^%changelog[[:space:]]*$/ { - print - print entry - inserted = 1 - next - } - { print } -' "$SPEC" > "$TMP" - -if ! grep -q '^%changelog' "$SPEC"; then - echo "error: no %changelog section in $SPEC — refusing to mangle" >&2 - rm -f "$TMP" - exit 1 -fi - -mv "$TMP" "$SPEC" - -echo "Added changelog entry for ${VERSION}:" -echo "$ENTRY" diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 3e136a4..5019ae8 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -82,7 +82,10 @@ jobs: sed -i "s/^Version:.*/Version: ${VERSION}/" cortex.spec - name: Generate changelog entry - run: bash .gitea/scripts/generate-rpm-changelog.sh cortex.spec "${{ steps.version.outputs.VERSION }}" + uses: https://git.lair.cafe/actions/rpm-changelog@v1 + with: + spec: cortex.spec + version: ${{ steps.version.outputs.VERSION }} - name: Generate source tarball run: | @@ -139,7 +142,10 @@ jobs: sed -i "s/^Version:.*/Version: ${VERSION}/" neuron.spec - name: Generate changelog entry - run: bash .gitea/scripts/generate-rpm-changelog.sh neuron.spec "${{ steps.version.outputs.VERSION }}" + uses: https://git.lair.cafe/actions/rpm-changelog@v1 + with: + spec: neuron.spec + version: ${{ steps.version.outputs.VERSION }} - name: Generate source tarball run: |