From 8b8b9a6d432624ec757895c95403f6768ef70c9a Mon Sep 17 00:00:00 2001 From: Karol Labus Date: Thu, 17 Sep 2026 21:29:50 +0200 Subject: [PATCH] fix: refine python release workflow script with dynamic timestamp --- .gitea/workflows/release.yml | 203 +++++++++++++++++++++-------------- 1 file changed, 125 insertions(+), 78 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 67d6d3d..d24c4f9 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -46,59 +46,99 @@ jobs: echo "md5_9=$MD5_SUM_9" >> $GITHUB_OUTPUT echo "md5_10=$MD5_SUM_10" >> $GITHUB_OUTPUT - - name: Create Gitea Release + - name: Publish Release and Update Manifest + env: + API_URL: ${{ github.api_url }} + REPO: ${{ github.repository }} + TOKEN: ${{ github.token }} + TAG: ${{ github.ref_name }} + MD5_9: ${{ steps.checksum.outputs.md5_9 }} + MD5_10: ${{ steps.checksum.outputs.md5_10 }} run: | - API_URL="${{ github.api_url }}" - REPO="${{ github.repository }}" - TOKEN="${{ github.token }}" - TAG="${{ github.ref_name }}" - - IS_PRERELEASE="false" - if [[ "$TAG" =~ beta|alpha|^v0\. ]]; then - IS_PRERELEASE="true" - fi - - # Check if release exists - EXISTING_REL=$(curl -s -H "Authorization: token $TOKEN" "$API_URL/repos/$REPO/releases/tags/$TAG") - REL_ID=$(echo "$EXISTING_REL" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2) - - if [ -z "$REL_ID" ] || [ "$REL_ID" == "null" ]; then - RELEASE_RES=$(curl -s -X POST "$API_URL/repos/$REPO/releases" \ - -H "Authorization: token $TOKEN" \ - -H "Content-Type: application/json" \ - -d "{\"tag_name\":\"$TAG\", \"name\":\"Release $TAG\", \"body\":\"Automated release\", \"draft\":false, \"prerelease\":$IS_PRERELEASE}") - REL_ID=$(echo "$RELEASE_RES" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2) - fi - - # Delete existing assets for this release if present - ASSETS=$(curl -s -H "Authorization: token $TOKEN" "$API_URL/repos/$REPO/releases/$REL_ID/assets") - echo "$ASSETS" | grep -o '"id":[0-9]*' | cut -d':' -f2 | while read -r asset_id; do - if [ -n "$asset_id" ]; then - curl -s -X DELETE -H "Authorization: token $TOKEN" "$API_URL/repos/$REPO/releases/$REL_ID/assets/$asset_id" - fi - done + python3 -c ' + import os, json, urllib.request, base64, datetime - # Upload Assets - curl -s -X POST "$API_URL/repos/$REPO/releases/$REL_ID/assets" \ - -H "Authorization: token $TOKEN" \ - -F "attachment=@BlackBarRemover_${TAG}_jf10.11.zip" - - curl -s -X POST "$API_URL/repos/$REPO/releases/$REL_ID/assets" \ - -H "Authorization: token $TOKEN" \ - -F "attachment=@BlackBarRemover_${TAG}_jf12.0.zip" + api_url = os.environ["API_URL"] + repo = os.environ["REPO"] + token = os.environ["TOKEN"] + tag = os.environ["TAG"] + md5_9 = os.environ["MD5_9"] + md5_10 = os.environ["MD5_10"] - - name: Update manifest.json via API - run: | - API_URL="${{ github.api_url }}" - REPO="${{ github.repository }}" - TOKEN="${{ github.token }}" - - VERSION="${{ github.ref_name }}" - VERSION="${VERSION#v}" - CLEAN_VERSION="${VERSION%%-*}" - - cat > manifest.json <