Update gitea workflow
This commit is contained in:
@@ -51,24 +51,37 @@ 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
|
||||||
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
|
# workflow runner starts, so retry a few times before giving up.
|
||||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
RELEASE_ID=""
|
||||||
-H "Content-Type: application/json" \
|
for attempt in 1 2 3 4 5; do
|
||||||
"${GITEA_URL}/api/v1/repos/${REPO}/releases" \
|
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
|
||||||
-d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}")
|
-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)
|
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'])")
|
||||||
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
RELEASE_ID=$(echo "$BODY" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
|
|
||||||
|
|
||||||
# Upload binary asset
|
# Upload binary asset
|
||||||
BINARY="mikebase-${TAG}-x86_64-linux"
|
BINARY="mikebase-${TAG}-x86_64-linux"
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
|
|||||||
Reference in New Issue
Block a user