diff --git a/.gitea/workflows/BuildAndRelease.yml b/.gitea/workflows/BuildAndRelease.yml deleted file mode 100644 index 2d1bd1a..0000000 --- a/.gitea/workflows/BuildAndRelease.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Build + Release - -on: - push: - tags: - - "v*" - -jobs: - zip: - runs-on: debian-12 - - steps: - - name: Tools installieren - run: | - apt-get update - apt-get install -y git zip curl - - - 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: ZIP bauen - run: | - cd /tmp/repo - git archive --format=zip --output=/tmp/HailMaryGuildTools-${GITEA_REF_NAME}.zip HEAD - ls -lh /tmp/HailMaryGuildTools-${GITEA_REF_NAME}.zip - - - name: ZIP hochladen - run: | - curl --fail \ - --user "Torsten:${{ secrets.PAT_TOKEN }}" \ - --upload-file "/tmp/HailMaryGuildTools-${GITEA_REF_NAME}.zip" \ - "http://10.10.2.140:3000/api/packages/Torsten/generic/HailMaryGuildTools/${GITEA_REF_NAME}/HailMaryGuildTools-${GITEA_REF_NAME}.zip" \ No newline at end of file diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml new file mode 100644 index 0000000..3a699b5 --- /dev/null +++ b/.gitea/workflows/release.yml @@ -0,0 +1,65 @@ +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 + + - 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 + run: | + 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 + run: | + 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 + 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: | + 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-on-main.yml b/.gitea/workflows/tag-on-main.yml new file mode 100644 index 0000000..a01a45a --- /dev/null +++ b/.gitea/workflows/tag-on-main.yml @@ -0,0 +1,51 @@ +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