diff --git a/.gitea/workflows/create-major-tag.yml b/.gitea/workflows/create-major-tag.yml new file mode 100644 index 0000000..d8cf82d --- /dev/null +++ b/.gitea/workflows/create-major-tag.yml @@ -0,0 +1,58 @@ +name: Create Major Version Tag + +on: + release: + types: [published] + +jobs: + update-major-tag: + runs-on: ubuntu-latest + permissions: + contents: write # nötig zum Löschen/Erstellen von Tags + + steps: + # ▸ 1. Repository beim Release-Tag auschecken + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # alle Tags holen + ref: ${{ github.event.release.tag_name }} + + # ▸ 2. Hauptversion aus dem Release-Tag extrahieren + - name: Derive major version + id: derive + shell: bash + run: | + TAG="${{ github.event.release.tag_name }}" # z. B. v2.3.4 + echo "Release-Tag: $TAG" + + TAG_NOPREFIX="${TAG#v}" # entfernt führendes v/V + MAJOR="${TAG_NOPREFIX%%.*}" # nimmt Teil vor erstem Punkt + MAJOR_TAG="v${MAJOR}" # z. B. v2 + + echo "Major-Tag: $MAJOR_TAG" + echo "major_tag=$MAJOR_TAG" >>"$GITHUB_OUTPUT" + + # ▸ 3. Altes Major-Tag (falls vorhanden) löschen und neu anlegen + - name: Re-create major tag + env: + MAJOR_TAG: ${{ steps.derive.outputs.major_tag }} + RELEASE_TAG: ${{ github.event.release.tag_name }} + shell: bash + run: | + set -euo pipefail + + # Bestimmten Commit des Release-Tags ermitteln + COMMIT_SHA="$(git rev-list -n 1 "$RELEASE_TAG")" + + echo "Commit des Release-Tags: $COMMIT_SHA" + + # (a) Lokal + remote altes Major-Tag entfernen (falls es existiert) + git tag -d "$MAJOR_TAG" 2>/dev/null || true + git push --delete origin "$MAJOR_TAG" 2>/dev/null || true + + # (b) Neues annotiertes Tag erstellen und pushen + git tag -a "$MAJOR_TAG" "$COMMIT_SHA" \ + -m "Update $MAJOR_TAG → $RELEASE_TAG" + git push origin "$MAJOR_TAG" + + echo "✅ $MAJOR_TAG zeigt nun auf $RELEASE_TAG ($COMMIT_SHA)"