diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release-from-tag similarity index 74% rename from .gitea/workflows/release.yml rename to .gitea/workflows/release-from-tag index 3a699b5..f403c9e 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release-from-tag @@ -13,23 +13,30 @@ jobs: - name: Tools installieren run: | apt-get update - apt-get install -y git zip curl jq + apt-get install -y git zip curl jq rsync - name: Repo klonen run: | rm -rf /tmp/repo /tmp/build git clone http://oauth2:${{ secrets.PAT_TOKEN }}@10.10.2.140:3000/Torsten/HailMaryGuildTools.git /tmp/repo - - name: ZIP bauen mit Addon-Ordner + - name: ZIP mit Addon-Ordner bauen run: | + set -e mkdir -p /tmp/build/HailMaryGuildTools - cp -r /tmp/repo/* /tmp/build/HailMaryGuildTools/ - cd /tmp/build - zip -r /tmp/HailMaryGuildTools-${{ gitea.ref_name }}.zip HailMaryGuildTools - ls -lh /tmp/HailMaryGuildTools-${{ gitea.ref_name }}.zip - - name: Release anlegen oder laden + rsync -a \ + --exclude='.git' \ + --exclude='.gitea' \ + /tmp/repo/ /tmp/build/HailMaryGuildTools/ + + cd /tmp/build + zip -r "/tmp/HailMaryGuildTools-${{ gitea.ref_name }}.zip" HailMaryGuildTools + ls -lh "/tmp/HailMaryGuildTools-${{ gitea.ref_name }}.zip" + + - name: Release anlegen oder vorhandene laden run: | + set -e TAG="${{ gitea.ref_name }}" API="http://10.10.2.140:3000/api/v1/repos/Torsten/HailMaryGuildTools" @@ -38,8 +45,9 @@ jobs: "$API/releases/tags/$TAG") if [ "$HTTP_CODE" = "200" ]; then - echo "Release existiert bereits" + echo "Release existiert bereits." else + echo "Release wird erstellt." curl --fail -s \ -H "Authorization: token ${{ secrets.PAT_TOKEN }}" \ -H "Content-Type: application/json" \ @@ -56,6 +64,7 @@ jobs: - name: ZIP an Release anhängen run: | + set -e RELEASE_ID=$(jq -r '.id' /tmp/release.json) FILE="/tmp/HailMaryGuildTools-${{ gitea.ref_name }}.zip" 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 diff --git a/.gitea/workflows/tag-on-main.yml b/.gitea/workflows/tag-on-main.yml deleted file mode 100644 index a01a45a..0000000 --- a/.gitea/workflows/tag-on-main.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Auto Tag on Main - -on: - push: - branches: - - main - -jobs: - tag: - runs-on: debian-12 - - steps: - - name: Tools installieren - run: | - apt-get update - apt-get install -y git - - - 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: Nächstes Patch-Tag berechnen und pushen - run: | - set -e - cd /tmp/repo - - git fetch --tags - - LAST_TAG=$(git tag -l 'v*' --sort=-version:refname | head -n 1) - - if [ -z "$LAST_TAG" ]; then - NEW_TAG="v1.0.0" - else - VERSION="${LAST_TAG#v}" - MAJOR=$(echo "$VERSION" | cut -d. -f1) - MINOR=$(echo "$VERSION" | cut -d. -f2) - PATCH=$(echo "$VERSION" | cut -d. -f3) - - PATCH=$((PATCH + 1)) - NEW_TAG="v${MAJOR}.${MINOR}.${PATCH}" - fi - - echo "Letzter Tag: ${LAST_TAG:-keiner}" - echo "Neuer Tag: $NEW_TAG" - - git config user.name "Gitea Actions" - git config user.email "actions@local" - - git tag "$NEW_TAG" - git push origin "$NEW_TAG" \ No newline at end of file