From 9a6b5e9b4c35c8b8c390c623b9613f2354d1d199 Mon Sep 17 00:00:00 2001 From: Erik Simon Date: Wed, 29 Jul 2026 20:39:08 +0200 Subject: [PATCH 1/3] Add Gitea Actions workflow to enforce and automate version bumps on PRs to master Co-Authored-By: Claude Sonnet 5 --- .gitea/workflows/version-bump.yml | 89 +++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .gitea/workflows/version-bump.yml diff --git a/.gitea/workflows/version-bump.yml b/.gitea/workflows/version-bump.yml new file mode 100644 index 0000000..285875b --- /dev/null +++ b/.gitea/workflows/version-bump.yml @@ -0,0 +1,89 @@ +name: Version Bump + +on: + pull_request: + branches: [master] + types: [opened, synchronize, reopened, labeled, unlabeled, closed] + +permissions: + contents: write + +jobs: + # Register this job's name as a required status check on master's branch + # protection - that's what actually blocks the merge button. + check-bump-label: + if: github.event.action != 'closed' + runs-on: ubuntu-latest + steps: + - name: Require a bump:major/minor/patch label + env: + LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }} + run: | + echo "$LABELS" | grep -qE '"bump:(major|minor|patch)"' || { + echo "::error::PR into master must carry one of bump:major, bump:minor, bump:patch" + exit 1 + } + + # Runs once, after the merge has already happened, to commit the actual + # version bump onto master. + apply-version-bump: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: master + fetch-depth: 0 + + - name: Determine bump level from PR labels + id: level + env: + LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }} + run: | + for lvl in major minor patch; do + if echo "$LABELS" | grep -q "\"bump:$lvl\""; then + echo "level=$lvl" >> "$GITHUB_OUTPUT" + exit 0 + fi + done + echo "::error::merged PR into master has no bump:major/minor/patch label" + exit 1 + + - name: Bump CMakeLists.txt and flake.nix + env: + LEVEL: ${{ steps.level.outputs.level }} + run: | + set -euo pipefail + + CURRENT=$(grep -oP '(?<=VERSION )[0-9]+(\.[0-9]+){1,2}' CMakeLists.txt | head -1) + + # Pad to 3 components so a pre-existing 2-component version (e.g. + # "0.1") still splits into MAJOR/MINOR/PATCH correctly. + IFS='.' read -r MAJOR MINOR PATCH <<< "${CURRENT}.0.0" + + case "$LEVEL" in + major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;; + minor) MINOR=$((MINOR + 1)); PATCH=0 ;; + patch) PATCH=$((PATCH + 1)) ;; + esac + + NEW="$MAJOR.$MINOR.$PATCH" + + sed -i "s/VERSION ${CURRENT}/VERSION ${NEW}/" CMakeLists.txt + sed -i "s/version = \"${CURRENT}\"/version = \"${NEW}\"/" flake.nix + + echo "CURRENT_VERSION=${CURRENT}" >> "$GITHUB_ENV" + echo "NEW_VERSION=${NEW}" >> "$GITHUB_ENV" + + - name: Commit and push + run: | + set -euo pipefail + if [ "$CURRENT_VERSION" = "$NEW_VERSION" ]; then + echo "::error::version did not change (${CURRENT_VERSION} -> ${NEW_VERSION})" + exit 1 + fi + git config user.name "gitea-actions" + git config user.email "actions@noreply.localhost" + git add CMakeLists.txt flake.nix + git commit -m "Bump version to ${NEW_VERSION}" + git push origin HEAD:master From 44689cca8d6c67e64541e2040e669b5022918101 Mon Sep 17 00:00:00 2001 From: Erik Simon Date: Wed, 29 Jul 2026 21:12:03 +0200 Subject: [PATCH 2/3] Switch version-bump labels to bump/ scope and add bump/skip Co-Authored-By: Claude Sonnet 5 --- .gitea/workflows/version-bump.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/version-bump.yml b/.gitea/workflows/version-bump.yml index 285875b..99d1b67 100644 --- a/.gitea/workflows/version-bump.yml +++ b/.gitea/workflows/version-bump.yml @@ -15,12 +15,12 @@ jobs: if: github.event.action != 'closed' runs-on: ubuntu-latest steps: - - name: Require a bump:major/minor/patch label + - name: Require a bump/major, bump/minor, bump/patch, or bump/skip label env: LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }} run: | - echo "$LABELS" | grep -qE '"bump:(major|minor|patch)"' || { - echo "::error::PR into master must carry one of bump:major, bump:minor, bump:patch" + echo "$LABELS" | grep -qE '"bump/(major|minor|patch|skip)"' || { + echo "::error::PR into master must carry one of bump/major, bump/minor, bump/patch, bump/skip" exit 1 } @@ -40,16 +40,17 @@ jobs: env: LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }} run: | - for lvl in major minor patch; do - if echo "$LABELS" | grep -q "\"bump:$lvl\""; then + for lvl in major minor patch skip; do + if echo "$LABELS" | grep -q "\"bump/$lvl\""; then echo "level=$lvl" >> "$GITHUB_OUTPUT" exit 0 fi done - echo "::error::merged PR into master has no bump:major/minor/patch label" + echo "::error::merged PR into master has no bump/major, bump/minor, bump/patch, or bump/skip label" exit 1 - name: Bump CMakeLists.txt and flake.nix + if: steps.level.outputs.level != 'skip' env: LEVEL: ${{ steps.level.outputs.level }} run: | @@ -76,6 +77,7 @@ jobs: echo "NEW_VERSION=${NEW}" >> "$GITHUB_ENV" - name: Commit and push + if: steps.level.outputs.level != 'skip' run: | set -euo pipefail if [ "$CURRENT_VERSION" = "$NEW_VERSION" ]; then From b1bb4aeceaae499e7cf407a2392fc80de62138d4 Mon Sep 17 00:00:00 2001 From: Erik Simon Date: Wed, 29 Jul 2026 21:13:44 +0200 Subject: [PATCH 3/3] Scope version-bump workflow to PRs targeting develop Co-Authored-By: Claude Sonnet 5 --- .gitea/workflows/version-bump.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/version-bump.yml b/.gitea/workflows/version-bump.yml index 99d1b67..069a9f5 100644 --- a/.gitea/workflows/version-bump.yml +++ b/.gitea/workflows/version-bump.yml @@ -2,14 +2,14 @@ name: Version Bump on: pull_request: - branches: [master] + branches: [develop] types: [opened, synchronize, reopened, labeled, unlabeled, closed] permissions: contents: write jobs: - # Register this job's name as a required status check on master's branch + # Register this job's name as a required status check on develop's branch # protection - that's what actually blocks the merge button. check-bump-label: if: github.event.action != 'closed' @@ -20,19 +20,19 @@ jobs: LABELS: ${{ toJson(github.event.pull_request.labels.*.name) }} run: | echo "$LABELS" | grep -qE '"bump/(major|minor|patch|skip)"' || { - echo "::error::PR into master must carry one of bump/major, bump/minor, bump/patch, bump/skip" + echo "::error::PR into develop must carry one of bump/major, bump/minor, bump/patch, bump/skip" exit 1 } # Runs once, after the merge has already happened, to commit the actual - # version bump onto master. + # version bump onto develop. apply-version-bump: if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: - ref: master + ref: develop fetch-depth: 0 - name: Determine bump level from PR labels @@ -46,7 +46,7 @@ jobs: exit 0 fi done - echo "::error::merged PR into master has no bump/major, bump/minor, bump/patch, or bump/skip label" + echo "::error::merged PR into develop has no bump/major, bump/minor, bump/patch, or bump/skip label" exit 1 - name: Bump CMakeLists.txt and flake.nix @@ -88,4 +88,4 @@ jobs: git config user.email "actions@noreply.localhost" git add CMakeLists.txt flake.nix git commit -m "Bump version to ${NEW_VERSION}" - git push origin HEAD:master + git push origin HEAD:develop