diff --git a/bb64/publish.sh b/bb64/publish.sh index 8ce41b1..d4a0025 100755 --- a/bb64/publish.sh +++ b/bb64/publish.sh @@ -105,12 +105,20 @@ echo "Getting or creating release $TAG on Gitea..." EXISTING_RELEASE=$(curl -s -X GET "$API_URL/releases/tags/$TAG" \ -H "Authorization: token $RELEASE_WRITE_TOKEN") +echo "Existing release check response: $EXISTING_RELEASE" >&2 + if echo "$EXISTING_RELEASE" | grep -q '"id":[0-9]*'; then # Release already exists, get its ID RELEASE_ID=$(echo "$EXISTING_RELEASE" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2) echo "Release $TAG already exists with ID: $RELEASE_ID" else - # Create new release + # Create new release only if tag was just created + if [ "$TAG_EXISTS_ON_REMOTE" = true ]; then + echo "Tag exists on remote but no release found - this shouldn't happen" >&2 + echo "API response was: $EXISTING_RELEASE" >&2 + exit 1 + fi + echo "Creating new release $TAG on Gitea..." RELEASE_RESPONSE=$(curl -s -X POST "$API_URL/releases" \ -H "Content-Type: application/json" \