From 340b9c63d06885243b191ce23b2d656046adf5dd Mon Sep 17 00:00:00 2001 From: Torsten Brendgen Date: Sat, 11 Apr 2026 22:51:14 +0200 Subject: [PATCH] init 2.0.0 --- .gitea/workflows/release-from-tag.yml | 74 +++++++++++++++++++++++++++ .gitea/workflows/tag-from-toc.yml | 14 ++--- 2 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 .gitea/workflows/release-from-tag.yml diff --git a/.gitea/workflows/release-from-tag.yml b/.gitea/workflows/release-from-tag.yml new file mode 100644 index 0000000..964c0a4 --- /dev/null +++ b/.gitea/workflows/release-from-tag.yml @@ -0,0 +1,74 @@ +name: Build Release ZIP + +on: + push: + tags: + - "v*" + +jobs: + release: + runs-on: debian-12 + + steps: + - name: Tools installieren + run: | + apt-get update + 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 mit Addon-Ordner bauen + run: | + set -e + mkdir -p /tmp/build/HailMaryGuildTools + + 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 laden + run: | + set -e + TAG="${{ gitea.ref_name }}" + API="http://10.10.2.140:3000/api/v1/repos/Torsten/HailMaryGuildTools" + + HTTP_CODE=$(curl -s -o /tmp/release.json -w "%{http_code}" \ + -H "Authorization: token ${{ secrets.PAT_TOKEN }}" \ + "$API/releases/tags/$TAG") + + if [ "$HTTP_CODE" = "200" ]; then + echo "Release existiert bereits." + else + echo "Release wird erstellt." + curl --fail -s \ + -H "Authorization: token ${{ secrets.PAT_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d "{ + \"tag_name\": \"$TAG\", + \"name\": \"HailMaryGuildTools $TAG\", + \"draft\": false, + \"prerelease\": false + }" \ + "$API/releases" > /tmp/release.json + fi + + jq '.id, .tag_name, .html_url' /tmp/release.json + + - name: ZIP an Release anhängen + run: | + set -e + RELEASE_ID=$(jq -r '.id' /tmp/release.json) + FILE="/tmp/HailMaryGuildTools-${{ gitea.ref_name }}.zip" + + curl --fail \ + -H "Authorization: token ${{ secrets.PAT_TOKEN }}" \ + -F "attachment=@${FILE}" \ + "http://10.10.2.140:3000/api/v1/repos/Torsten/HailMaryGuildTools/releases/${RELEASE_ID}/assets?name=$(basename "$FILE")" \ No newline at end of file diff --git a/.gitea/workflows/tag-from-toc.yml b/.gitea/workflows/tag-from-toc.yml index 9833cd0..c9d8a73 100644 --- a/.gitea/workflows/tag-from-toc.yml +++ b/.gitea/workflows/tag-from-toc.yml @@ -41,26 +41,26 @@ jobs: TAG="v$VERSION" - echo "VERSION=$VERSION" >> "$GITHUB_ENV" - echo "TAG=$TAG" >> "$GITHUB_ENV" - echo "Gefundene Version: $VERSION" echo "Neues Tag wäre: $TAG" + echo "$TAG" > /tmp/release_tag.txt + - name: Tag nur erstellen, wenn noch nicht vorhanden run: | set -e cd /tmp/repo git fetch --tags + TAG=$(cat /tmp/release_tag.txt) - if git rev-parse "${TAG}" >/dev/null 2>&1; then - echo "Tag ${TAG} existiert bereits, nichts zu tun." + 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 + git tag "$TAG" + git push origin "$TAG" \ No newline at end of file