From 46035ac4bebe2e8224a75068ce25489b271473fe Mon Sep 17 00:00:00 2001 From: Hidde Jansen Date: Sat, 11 Apr 2026 21:33:59 +0200 Subject: [PATCH] Update gitea workflow --- .gitea/workflows/release.yml | 37 ++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index fe2042c..6daff74 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -51,24 +51,37 @@ jobs: GITEA_URL: ${{ github.server_url }} REPO: ${{ github.repository }} TAG: ${{ github.ref_name }} + SHA: ${{ github.sha }} run: | - # Create the release - RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \ - -H "Authorization: token ${GITEA_TOKEN}" \ - -H "Content-Type: application/json" \ - "${GITEA_URL}/api/v1/repos/${REPO}/releases" \ - -d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}") + # 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 \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + "${GITEA_URL}/api/v1/repos/${REPO}/releases" \ + -d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"target_commitish\":\"${SHA}\",\"draft\":false,\"prerelease\":false}") - HTTP_CODE=$(echo "$RESPONSE" | tail -1) - BODY=$(echo "$RESPONSE" | head -1) + HTTP_CODE=$(echo "$RESPONSE" | tail -1) + BODY=$(echo "$RESPONSE" | head -1) - if [ "$HTTP_CODE" -ne 201 ]; then - echo "Failed to create release (HTTP $HTTP_CODE): $BODY" + if [ "$HTTP_CODE" -eq 201 ]; then + RELEASE_ID=$(echo "$BODY" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])") + break + fi + + 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 - RELEASE_ID=$(echo "$BODY" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])") - # Upload binary asset BINARY="mikebase-${TAG}-x86_64-linux" curl -s -X POST \