Update gitea workflow
This commit is contained in:
@@ -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 \
|
||||
|
||||
Reference in New Issue
Block a user