From 3871ffa3b0ba2ebff585f764f6637aadc34d7b5b Mon Sep 17 00:00:00 2001 From: DragonSlayer_14 Date: Sun, 13 Sep 2026 14:04:51 +0200 Subject: [PATCH] =?UTF-8?q?Feat:=20F=C3=BCgt=20automatischen=20Patch-Versi?= =?UTF-8?q?on-Bump=20f=C3=BCr=20Dev=E2=86=92Testing-PRs=20hinzu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01DrWxHCG7URf4FEy8Hja23f --- .gitea/workflows/version-bump.yaml | 84 ++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .gitea/workflows/version-bump.yaml diff --git a/.gitea/workflows/version-bump.yaml b/.gitea/workflows/version-bump.yaml new file mode 100644 index 0000000..dd25604 --- /dev/null +++ b/.gitea/workflows/version-bump.yaml @@ -0,0 +1,84 @@ +name: Auto Patch-Version-Bump (Dev → Testing PR) + +on: + pull_request: + types: [opened] + branches: + - testing + +jobs: + detect-changes: + name: Erkenne relevante Änderungen im PR + runs-on: ubuntu-latest + if: ${{ (gitea.head_ref || github.head_ref) == 'dev' }} + outputs: + code_changed: ${{ steps.filter.outputs.code }} + steps: + - name: Checkout Dev-Branch (PR-Head) + uses: actions/checkout@v7 + with: + ref: ${{ gitea.head_ref || github.head_ref }} + fetch-depth: 0 + + - name: Prüfe auf Änderungen an Cargo.toml, Cargo.lock oder src/ + uses: dorny/paths-filter@v4 + id: filter + with: + base: ${{ gitea.base_ref || github.base_ref }} + filters: | + code: + - 'Cargo.toml' + - 'Cargo.lock' + - 'src/**' + + bump-version: + name: Patch-Version erhöhen & auf Dev pushen + needs: detect-changes + if: needs.detect-changes.outputs.code_changed == 'true' + runs-on: ubuntu-latest + steps: + - name: Checkout Dev-Branch (PR-Head) + uses: actions/checkout@v7 + with: + ref: ${{ gitea.head_ref || github.head_ref }} + fetch-depth: 0 + token: ${{ secrets.PACKAGE_TOKEN || secrets.RELEASE_TOKEN || secrets.PUBLISH_TOKEN || secrets.API_TOKEN || secrets.PAT_TOKEN || secrets.CUSTOM_TOKEN || secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN || github.token }} + + - name: Ermittle Cargo-Version auf testing & dev + id: versions + run: | + git fetch origin testing --depth=1 + TESTING_VERSION="$(git show origin/testing:Cargo.toml | sed -n 's/^version = "\(.*\)"/\1/p' | head -n1)" + DEV_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" + echo "Version auf testing: ${TESTING_VERSION} / Version auf dev: ${DEV_VERSION}" + echo "testing_version=${TESTING_VERSION}" >> "$GITHUB_OUTPUT" + echo "dev_version=${DEV_VERSION}" >> "$GITHUB_OUTPUT" + + - name: Patch-Version um 1 erhöhen (Cargo.toml & Cargo.lock) + if: steps.versions.outputs.testing_version == steps.versions.outputs.dev_version + run: | + VERSION="${{ steps.versions.outputs.dev_version }}" + MAJOR="$(echo "$VERSION" | cut -d. -f1)" + MINOR="$(echo "$VERSION" | cut -d. -f2)" + PATCH="$(echo "$VERSION" | cut -d. -f3)" + NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))" + echo "Erhöhe Version: ${VERSION} -> ${NEW_VERSION}" + + sed -i "0,/^version = \"${VERSION}\"/s//version = \"${NEW_VERSION}\"/" Cargo.toml + + PACKAGE_NAME="$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml | head -n1)" + awk -v new="$NEW_VERSION" -v pkg="$PACKAGE_NAME" ' + found_name && /^version = "/ { + print "version = \"" new "\"" + found_name = 0 + next + } + $0 == "name = \"" pkg "\"" { found_name = 1 } + { print } + ' Cargo.lock > Cargo.lock.tmp && mv Cargo.lock.tmp Cargo.lock + + git config user.name "Gitea-Bot" + git config user.email "no-reply@creativedragonslayer.de" + git add Cargo.toml Cargo.lock + git commit -m "Chore: Erhöht Patch-Version auf ${NEW_VERSION} für Promotion nach testing" + git push origin HEAD:${{ gitea.head_ref || github.head_ref }}