feat(workflows): add workflow to create major version tags
- Introduces a GitHub Actions workflow to manage major version tags - Automates deriving and updating the major tag upon release publication - Improves release consistency and simplifies tag management
This commit is contained in:
58
.gitea/workflows/create-major-tag.yml
Normal file
58
.gitea/workflows/create-major-tag.yml
Normal file
@@ -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)"
|
Reference in New Issue
Block a user