diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index ca8c1f2..7edfa93 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -50,38 +50,28 @@ jobs: echo "Token length: ${#FORGEJO_TOKEN}" TAG="${{ github.event.inputs.tag || github.ref_name }}" - # use internal docker network URL instead of external - API_BASE="http://forgejo:3000/api/v1" + API_BASE="${{ github.server_url }}/api/v1" REPO="${{ github.repository }}" - # ensure tag exists (create at HEAD if not) - curl -s -X POST \ - -H "Authorization: token ${FORGEJO_TOKEN}" \ - -H "Content-Type: application/json" \ - -d "{\"tag_name\": \"${TAG}\"}" \ - "${API_BASE}/repos/${REPO}/tags" || true - - # get or create release echo "Looking for release: ${API_BASE}/repos/${REPO}/releases/tags/${TAG}" - RESPONSE=$(curl -s -H "Authorization: token ${FORGEJO_TOKEN}" \ - "${API_BASE}/repos/${REPO}/releases/tags/${TAG}") + RESPONSE=$(wget -qO- --header="Authorization: token ${FORGEJO_TOKEN}" \ + "${API_BASE}/repos/${REPO}/releases/tags/${TAG}" 2>/dev/null || echo '{}') echo "Lookup response: ${RESPONSE}" - RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id') + RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id // empty') - if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then + if [ -z "$RELEASE_ID" ]; then echo "Creating release for ${TAG}..." - RESPONSE=$(curl -s -X POST \ - -H "Content-Type: application/json" \ - -H "Authorization: token ${FORGEJO_TOKEN}" \ - -d '{"tag_name": "'"${TAG}"'", "name": "'"${TAG}"'"}' \ - "${API_BASE}/repos/${REPO}/releases") + RESPONSE=$(wget -qO- --header="Authorization: token ${FORGEJO_TOKEN}" \ + --header="Content-Type: application/json" \ + --post-data='{"tag_name": "'"${TAG}"'", "name": "'"${TAG}"'"}' \ + "${API_BASE}/repos/${REPO}/releases" 2>&1) echo "Create response: ${RESPONSE}" RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id') fi echo "Release ID: ${RELEASE_ID}" - # upload assets + # upload assets (still need curl for multipart) for file in lofivor-linux-x86_64 lofivor-windows-x86_64.exe; do echo "Uploading $file..." curl -sf -X POST \