From de3e7c75a5b78f1b40a828df35d0a780b8fbf35a Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 5 Sep 2025 11:27:32 -0400 Subject: [PATCH] v0.2.0 - New minor version --- build_and_push.sh | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/build_and_push.sh b/build_and_push.sh index 42137df..fa908e3 100755 --- a/build_and_push.sh +++ b/build_and_push.sh @@ -259,13 +259,24 @@ create_gitea_release() { if echo "$response" | grep -q '"id"'; then print_success "Created release $NEW_VERSION" - - # Upload binaries + upload_release_binaries "$api_url" "$token" + elif echo "$response" | grep -q "already exists"; then + print_warning "Release $NEW_VERSION already exists" upload_release_binaries "$api_url" "$token" else - print_warning "Release may already exist or creation failed" - print_status "Attempting to upload to existing release..." - upload_release_binaries "$api_url" "$token" + print_error "Failed to create release $NEW_VERSION" + print_error "Response: $response" + + # Try to check if the release exists anyway + print_status "Checking if release exists..." + local check_response=$(curl -s -H "Authorization: token $token" "$api_url/releases/tags/$NEW_VERSION") + if echo "$check_response" | grep -q '"id"'; then + print_warning "Release exists but creation response was unexpected" + upload_release_binaries "$api_url" "$token" + else + print_error "Release does not exist and creation failed" + return 1 + fi fi } @@ -274,16 +285,23 @@ upload_release_binaries() { local api_url="$1" local token="$2" - # Get release ID - local release_id=$(curl -s -H "Authorization: token $token" \ - "$api_url/releases/tags/$NEW_VERSION" | \ - grep -o '"id":[0-9]*' | head -n1 | cut -d: -f2) + # Get release ID with more robust parsing + print_status "Getting release ID for $NEW_VERSION..." + local response=$(curl -s -H "Authorization: token $token" "$api_url/releases/tags/$NEW_VERSION") + local release_id=$(echo "$response" | grep -o '"id":[0-9]*' | head -n1 | cut -d: -f2) if [[ -z "$release_id" ]]; then print_error "Could not get release ID for $NEW_VERSION" + print_error "API Response: $response" + + # Try to list all releases to debug + print_status "Available releases:" + curl -s -H "Authorization: token $token" "$api_url/releases" | grep -o '"tag_name":"[^"]*"' | head -5 return 1 fi + print_success "Found release ID: $release_id" + # Upload x86_64 binary if [[ -f "c-relay-x86_64" ]]; then print_status "Uploading x86_64 binary..."