From fea812d3a37c66844ed20331fc39405e7f779996 Mon Sep 17 00:00:00 2001 From: Karol Labus Date: Thu, 17 Sep 2026 21:15:28 +0200 Subject: [PATCH] fix: update manifest via Gitea API in release workflow --- .gitea/workflows/release.yml | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 872fa60..69b0afa 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -87,12 +87,11 @@ jobs: -H "Authorization: token $TOKEN" \ -F "attachment=@BlackBarRemover_${TAG}_jf12.0.zip" - - name: Update manifest.json + - name: Update manifest.json via API run: | - git config user.name "Gitea Actions" - git config user.email "actions@gitea.local" - - git checkout -B manifest + API_URL="${{ github.api_url }}" + REPO="${{ github.repository }}" + TOKEN="${{ github.token }}" VERSION="${{ github.ref_name }}" VERSION="${VERSION#v}" @@ -130,6 +129,20 @@ jobs: ] EOF - git add manifest.json - git commit -m "Update manifest for ${{ github.ref_name }}" - git push -f "https://${TOKEN}@gitea.local.labus.uk/${REPO}.git" manifest + B64_CONTENT=$(base64 -w0 manifest.json) + + # Update on manifest branch + EXISTING_MANIFEST=$(curl -s -H "Authorization: token $TOKEN" "$API_URL/repos/$REPO/contents/manifest.json?ref=manifest") + FILE_SHA=$(echo "$EXISTING_MANIFEST" | grep -o '"sha":"[^"]*"' | head -1 | cut -d'"' -f4) + + if [ -n "$FILE_SHA" ]; then + curl -s -X PUT "$API_URL/repos/$REPO/contents/manifest.json" \ + -H "Authorization: token $TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"content\":\"$B64_CONTENT\", \"message\":\"Update manifest.json for ${{ github.ref_name }}\", \"sha\":\"$FILE_SHA\", \"branch\":\"manifest\"}" + else + curl -s -X PUT "$API_URL/repos/$REPO/contents/manifest.json" \ + -H "Authorization: token $TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"content\":\"$B64_CONTENT\", \"message\":\"Create manifest.json for ${{ github.ref_name }}\", \"branch\":\"manifest\"}" + fi