From 2ca8715cb7805deb4039de26514f926b8fe77a4e Mon Sep 17 00:00:00 2001 From: DragonSlayer_14 Date: Sun, 13 Sep 2026 12:34:09 +0200 Subject: [PATCH 1/6] =?UTF-8?q?Feat:=20=C3=9Cberspringt=20Release/Publish?= =?UTF-8?q?=20bei=20bereits=20ver=C3=B6ffentlichter=20Version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prüft vor Build & Tests per Gitea Package-API, ob die aktuelle Crate-Version schon in der Registry existiert, und bricht den Release/Publish-Job dann gar nicht erst an, statt an einem Registry-Fehler zu scheitern. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01K2DxAVavuu4vMb2MC2G15g --- .gitea/workflows/main.yaml | 13 ++++++- scripts/check-version-published.py | 62 ++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 scripts/check-version-published.py diff --git a/.gitea/workflows/main.yaml b/.gitea/workflows/main.yaml index 8923552..8157f26 100644 --- a/.gitea/workflows/main.yaml +++ b/.gitea/workflows/main.yaml @@ -11,6 +11,7 @@ jobs: runs-on: ubuntu-latest outputs: code_changed: ${{ steps.filter.outputs.code }} + version_exists: ${{ steps.check-version.outputs.exists }} steps: - name: Checkout Repository uses: actions/checkout@v7 @@ -28,10 +29,20 @@ jobs: - '.cargo/**' - '.gitea/workflows/main.yaml' + - name: Prüfe ob Version bereits in der Registry existiert + id: check-version + if: steps.filter.outputs.code == 'true' + env: + GITEA_URL: ${{ gitea.server_url || github.server_url }} + REPO_OWNER: ${{ gitea.repository_owner || github.repository_owner }} + 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 }} + run: | + python3 scripts/check-version-published.py + release-and-publish: name: Build, Publish Crate to Gitea Registry & Create Release needs: detect-changes - if: needs.detect-changes.outputs.code_changed == 'true' + if: needs.detect-changes.outputs.code_changed == 'true' && needs.detect-changes.outputs.version_exists != 'true' runs-on: ubuntu-latest steps: - name: Checkout Repository diff --git a/scripts/check-version-published.py b/scripts/check-version-published.py new file mode 100644 index 0000000..8de68b7 --- /dev/null +++ b/scripts/check-version-published.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +"""Prüft, ob die aktuelle Crate-Version bereits in der Gitea Cargo-Registry existiert. + +Liest Name und Version aus Cargo.toml und fragt die Gitea Package-API ab. +Das Ergebnis wird als Step-Output "exists" (true/false) in GITHUB_OUTPUT +geschrieben, damit der Release/Publish-Job komplett übersprungen werden kann, +statt erst nach Build & Tests an einem "Version existiert bereits"-Fehler der +Registry zu scheitern. +""" + +import os +import re +import urllib.error +import urllib.request + + +def read_cargo_field(field, path="Cargo.toml"): + pattern = re.compile(rf'^{field}\s*=\s*"(.*)"') + with open(path) as f: + for line in f: + match = pattern.match(line.strip()) + if match: + return match.group(1) + raise SystemExit(f"Feld '{field}' nicht in {path} gefunden.") + + +def version_exists(gitea_url, owner, name, version, token): + url = f"{gitea_url}/api/v1/packages/{owner}/cargo/{name}/{version}" + req = urllib.request.Request(url, method="GET") + req.add_header("Authorization", f"token {token}") + try: + with urllib.request.urlopen(req, timeout=10) as resp: + return resp.status == 200 + except urllib.error.HTTPError as e: + if e.code == 404: + return False + raise + + +def main(): + gitea_url = os.environ["GITEA_URL"].strip().rstrip("/") + owner = os.environ["REPO_OWNER"].strip() + token = os.environ["TOKEN"].strip() + github_output = os.environ["GITHUB_OUTPUT"] + + name = read_cargo_field("name") + version = read_cargo_field("version") + + print(f"Prüfe {name}@{version} in der Gitea Cargo Registry...") + exists = version_exists(gitea_url, owner, name, version, token) + + if exists: + print(f"Version {version} existiert bereits in der Registry. Release/Publish wird übersprungen.") + else: + print(f"Version {version} ist neu.") + + with open(github_output, "a") as f: + f.write(f"exists={'true' if exists else 'false'}\n") + + +if __name__ == "__main__": + main() From 0b82945d81228cd07a0a17d96f91e330dad33619 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sun, 13 Sep 2026 12:02:16 +0000 Subject: [PATCH 2/6] chore(deps): update rust crate program-ctdra to v1.0.1 --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 46e8240..3130ce6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -54,9 +54,9 @@ dependencies = [ [[package]] name = "program-ctdra" -version = "1.0.0" +version = "1.0.1" source = "sparse+https://gitea.creative-dragonslayer.de/api/packages/Rust-Crates/cargo/" -checksum = "54f20af67f90bf6d10697dd77bb4beb41dafad7fe0fb46aacfc81ad45a8e48bd" +checksum = "528d5771916f74bdffb77ad60ea00c0ae4bd85f9a84e920cd65730a082133d67" [[package]] name = "quote" From b452f8406d5e314b7dd92af22354473fcb96cbff Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sun, 13 Sep 2026 12:02:20 +0000 Subject: [PATCH 3/6] chore(deps): update ghcr.io/renovatebot/renovate docker tag to v44.83.0 --- .gitea/workflows/renovate.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/renovate.yaml b/.gitea/workflows/renovate.yaml index f9f6456..ccbdcb2 100644 --- a/.gitea/workflows/renovate.yaml +++ b/.gitea/workflows/renovate.yaml @@ -9,7 +9,7 @@ jobs: renovate: name: Dependency-Updates prüfen & Pull Requests erstellen runs-on: ubuntu-latest - container: ghcr.io/renovatebot/renovate:44.82.0 + container: ghcr.io/renovatebot/renovate:44.83.0 steps: - name: Renovate ausführen run: renovate From e0cd7b8f3f342c362cef21412eb66a9d24b3d928 Mon Sep 17 00:00:00 2001 From: DragonSlayer_14 Date: Sun, 13 Sep 2026 14:04:51 +0200 Subject: [PATCH 4/6] =?UTF-8?q?Feat:=20F=C3=BCgt=20automatischen=20Patch-V?= =?UTF-8?q?ersion-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 }} From d902812919e3834b8978bd529db3f5b649164623 Mon Sep 17 00:00:00 2001 From: DragonSlayer_14 Date: Sun, 13 Sep 2026 14:26:01 +0200 Subject: [PATCH 5/6] =?UTF-8?q?Feat:=20F=C3=BCgt=20automatischen=20PR-Work?= =?UTF-8?q?flow=20f=C3=BCr=20Testing=E2=86=92Main=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_01AjPGeW28DpjnMkuvLSRTKv --- .gitea/workflows/testing-to-main-pr.yaml | 111 +++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 .gitea/workflows/testing-to-main-pr.yaml diff --git a/.gitea/workflows/testing-to-main-pr.yaml b/.gitea/workflows/testing-to-main-pr.yaml new file mode 100644 index 0000000..f26a71d --- /dev/null +++ b/.gitea/workflows/testing-to-main-pr.yaml @@ -0,0 +1,111 @@ +name: Auto-PR (Testing → Main) + +on: + push: + branches: + - testing + +jobs: + create-pr: + name: Erstelle automatisch PR von testing nach main + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - name: Prüfe auf bereits offenen PR nach main + id: check_pr + env: + GITEA_URL: ${{ gitea.server_url || github.server_url }} + REPO: ${{ gitea.repository || github.repository }} + 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 }} + run: | + OPEN_PRS=$(curl -s -H "Authorization: token ${TOKEN}" "${GITEA_URL}/api/v1/repos/${REPO}/pulls?state=open&limit=50") + EXISTS=$(echo "$OPEN_PRS" | jq -r '[.[] | select(.base.ref == "main" and .head.ref == "testing")] | length') + echo "Bereits offene testing→main PRs: ${EXISTS}" + echo "exists=${EXISTS}" >> "$GITHUB_OUTPUT" + + - name: Ermittle Versionen auf main & testing + id: versions + if: steps.check_pr.outputs.exists == '0' + run: | + git fetch origin main + MAIN_VERSION="$(git show origin/main:Cargo.toml | sed -n 's/^version = "\(.*\)"/\1/p' | head -n1)" + TESTING_VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" + echo "Version auf main: ${MAIN_VERSION} / Version auf testing: ${TESTING_VERSION}" + echo "main_version=${MAIN_VERSION}" >> "$GITHUB_OUTPUT" + echo "testing_version=${TESTING_VERSION}" >> "$GITHUB_OUTPUT" + + - name: Ermittle geänderte Kategorien (main...testing) + id: categories + if: steps.check_pr.outputs.exists == '0' && steps.versions.outputs.main_version == steps.versions.outputs.testing_version + run: | + CHANGED_FILES="$(git diff --name-only origin/main...HEAD)" + echo "Geänderte Dateien main...testing:" + echo "$CHANGED_FILES" + + WORKFLOWS="false" + CONFIG="false" + DOCS="false" + + if echo "$CHANGED_FILES" | grep -q '^\.gitea/workflows/'; then + WORKFLOWS="true" + fi + if echo "$CHANGED_FILES" | grep -qE '^(renovate\.json|qodana\.yaml|Cargo\.toml|Cargo\.lock|\.cargo/)'; then + CONFIG="true" + fi + if echo "$CHANGED_FILES" | grep -qE '(^|/)[^/]+\.md$|^LICENSE$'; then + DOCS="true" + fi + + echo "workflows=${WORKFLOWS}" >> "$GITHUB_OUTPUT" + echo "config=${CONFIG}" >> "$GITHUB_OUTPUT" + echo "docs=${DOCS}" >> "$GITHUB_OUTPUT" + + - name: Bestimme PR-Titel + id: title + if: steps.check_pr.outputs.exists == '0' + run: | + if [ "${{ steps.versions.outputs.main_version }}" != "${{ steps.versions.outputs.testing_version }}" ]; then + TITLE="Merge testing in main: Release ${{ steps.versions.outputs.testing_version }}" + else + PARTS=() + [ "${{ steps.categories.outputs.workflows }}" = "true" ] && PARTS+=("Workflows") + [ "${{ steps.categories.outputs.config }}" = "true" ] && PARTS+=("Konfigurationen") + [ "${{ steps.categories.outputs.docs }}" = "true" ] && PARTS+=("Dokumentation") + + if [ ${#PARTS[@]} -eq 0 ]; then + TITLE="Merge testing in main" + else + JOINED="" + for PART in "${PARTS[@]}"; do + if [ -z "$JOINED" ]; then + JOINED="$PART" + else + JOINED="${JOINED} & ${PART}" + fi + done + TITLE="Merge testing in main: ${JOINED} aktualisiert" + fi + fi + echo "Ermittelter PR-Titel: ${TITLE}" + echo "title=${TITLE}" >> "$GITHUB_OUTPUT" + + - name: Erstelle PR (testing -> main) + if: steps.check_pr.outputs.exists == '0' + env: + GITEA_URL: ${{ gitea.server_url || github.server_url }} + REPO: ${{ gitea.repository || github.repository }} + 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 }} + TITLE: ${{ steps.title.outputs.title }} + run: | + PAYLOAD=$(jq -n --arg title "$TITLE" --arg head "testing" --arg base "main" \ + '{title: $title, head: $head, base: $base}') + curl -f -s -S -X POST \ + -H "Authorization: token ${TOKEN}" \ + -H "Content-Type: application/json" \ + -d "$PAYLOAD" \ + "${GITEA_URL}/api/v1/repos/${REPO}/pulls" + echo "PR erstellt: ${TITLE}" From cbff7f3351b66d99dd53c7867086799140cccf75 Mon Sep 17 00:00:00 2001 From: Gitea-Bot Date: Sun, 13 Sep 2026 12:36:38 +0000 Subject: [PATCH 6/6] =?UTF-8?q?Chore:=20Erh=C3=B6ht=20Patch-Version=20auf?= =?UTF-8?q?=201.0.5=20f=C3=BCr=20Promotion=20nach=20testing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3130ce6..2892bf2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,7 +16,7 @@ checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" [[package]] name = "logger-ctdra" -version = "1.0.4" +version = "1.0.5" dependencies = [ "program-ctdra", "time", diff --git a/Cargo.toml b/Cargo.toml index a07db2e..ece5d05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "logger-ctdra" -version = "1.0.4" +version = "1.0.5" edition = "2024" authors = ['DragonSlayer_14'] readme = "README.md"