Update gitea workflow

This commit is contained in:
Ganonmaster
2026-04-11 21:33:59 +02:00
parent b4a887603e
commit 80cbc66878
+19 -6
View File
@@ -51,23 +51,36 @@ jobs:
GITEA_URL: ${{ github.server_url }} GITEA_URL: ${{ github.server_url }}
REPO: ${{ github.repository }} REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }} TAG: ${{ github.ref_name }}
SHA: ${{ github.sha }}
run: | run: |
# Create the release # Gitea may not have finished processing the tag ref by the time the
# workflow runner starts, so retry a few times before giving up.
RELEASE_ID=""
for attempt in 1 2 3 4 5; do
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \ RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
-H "Authorization: token ${GITEA_TOKEN}" \ -H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
"${GITEA_URL}/api/v1/repos/${REPO}/releases" \ "${GITEA_URL}/api/v1/repos/${REPO}/releases" \
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}") -d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"target_commitish\":\"${SHA}\",\"draft\":false,\"prerelease\":false}")
HTTP_CODE=$(echo "$RESPONSE" | tail -1) HTTP_CODE=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | head -1) BODY=$(echo "$RESPONSE" | head -1)
if [ "$HTTP_CODE" -ne 201 ]; then if [ "$HTTP_CODE" -eq 201 ]; then
echo "Failed to create release (HTTP $HTTP_CODE): $BODY" RELEASE_ID=$(echo "$BODY" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
exit 1 break
fi fi
RELEASE_ID=$(echo "$BODY" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])") echo "Attempt $attempt failed (HTTP $HTTP_CODE): $BODY"
if [ "$attempt" -lt 5 ]; then
sleep $((attempt * 5))
fi
done
if [ -z "$RELEASE_ID" ]; then
echo "Failed to create release after 5 attempts"
exit 1
fi
# Upload binary asset # Upload binary asset
BINARY="mikebase-${TAG}-x86_64-linux" BINARY="mikebase-${TAG}-x86_64-linux"