diff --git a/.gitea/workflows/tag-from-toc.yml b/.gitea/workflows/tag-from-toc.yml new file mode 100644 index 0000000..9833cd0 --- /dev/null +++ b/.gitea/workflows/tag-from-toc.yml @@ -0,0 +1,66 @@ +name: Tag from TOC Version + +on: + push: + branches: + - main + +jobs: + tag: + runs-on: debian-12 + + steps: + - name: Tools installieren + run: | + apt-get update + apt-get install -y git grep sed + + - name: Repo klonen + run: | + rm -rf /tmp/repo + git clone http://oauth2:${{ secrets.PAT_TOKEN }}@10.10.2.140:3000/Torsten/HailMaryGuildTools.git /tmp/repo + + - name: Version aus TOC lesen + run: | + set -e + cd /tmp/repo + + TOC_FILE="HailMaryGuildTools.toc" + + if [ ! -f "$TOC_FILE" ]; then + echo "TOC-Datei nicht gefunden: $TOC_FILE" + exit 1 + fi + + VERSION=$(grep '^## Version:' "$TOC_FILE" | sed 's/^## Version:[[:space:]]*//') + + if [ -z "$VERSION" ]; then + echo "Keine Version in $TOC_FILE gefunden" + exit 1 + fi + + TAG="v$VERSION" + + echo "VERSION=$VERSION" >> "$GITHUB_ENV" + echo "TAG=$TAG" >> "$GITHUB_ENV" + + echo "Gefundene Version: $VERSION" + echo "Neues Tag wäre: $TAG" + + - name: Tag nur erstellen, wenn noch nicht vorhanden + run: | + set -e + cd /tmp/repo + + git fetch --tags + + if git rev-parse "${TAG}" >/dev/null 2>&1; then + echo "Tag ${TAG} existiert bereits, nichts zu tun." + exit 0 + fi + + git config user.name "Gitea Actions" + git config user.email "actions@local" + + git tag "${TAG}" + git push origin "${TAG}" \ No newline at end of file