diff --git a/c-relay-7.0.0.tar.gz b/c-relay-7.0.0.tar.gz new file mode 100644 index 0000000..b659cfb Binary files /dev/null and b/c-relay-7.0.0.tar.gz differ diff --git a/increment_and_push.sh b/increment_and_push.sh index 1c17756..5369856 100755 --- a/increment_and_push.sh +++ b/increment_and_push.sh @@ -8,10 +8,10 @@ YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' -print_status() { echo -e "${BLUE}[INFO]${NC} $1"; } -print_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; } -print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; } -print_error() { echo -e "${RED}[ERROR]${NC} $1"; } +print_status() { echo -e "${BLUE}[INFO]${NC} $1" >&2; } +print_success() { echo -e "${GREEN}[SUCCESS]${NC} $1" >&2; } +print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1" >&2; } +print_error() { echo -e "${RED}[ERROR]${NC} $1" >&2; } # Global variables COMMIT_MESSAGE="" @@ -366,23 +366,38 @@ upload_release_assets() { local token=$(cat "$HOME/.gitea_token" | tr -d '\n\r') local api_url="https://git.laantungir.net/api/v1/repos/laantungir/c-relay" + local assets_url="$api_url/releases/$release_id/assets" + print_status "Assets URL: $assets_url" # Upload binary if [[ -f "$binary_path" ]]; then print_status "Uploading binary: $(basename "$binary_path")" - print_status "Debug: API URL: $api_url/releases/$release_id/assets" - print_status "Debug: Binary path: $binary_path" - print_status "Debug: Binary exists: $(ls -la "$binary_path" 2>/dev/null || echo "NOT FOUND")" - local binary_response=$(curl -v -X POST "$api_url/releases/$release_id/assets" \ - -H "Authorization: token $token" \ - -F "attachment=@$binary_path;filename=$(basename "$binary_path")" 2>&1) - if echo "$binary_response" | grep -q '"id"'; then - print_success "Uploaded binary successfully" - else - print_warning "Failed to upload binary" - print_warning "Response: $binary_response" - fi + # Retry loop for eventual consistency + local max_attempts=3 + local attempt=1 + while [[ $attempt -le $max_attempts ]]; do + print_status "Upload attempt $attempt/$max_attempts" + local binary_response=$(curl -fS -X POST "$assets_url" \ + -H "Authorization: token $token" \ + -F "attachment=@$binary_path;filename=$(basename "$binary_path")" \ + -F "name=$(basename "$binary_path")") + + if echo "$binary_response" | grep -q '"id"'; then + print_success "Uploaded binary successfully" + break + else + print_warning "Upload attempt $attempt failed" + if [[ $attempt -lt $max_attempts ]]; then + print_status "Retrying in 2 seconds..." + sleep 2 + else + print_error "Failed to upload binary after $max_attempts attempts" + print_error "Response: $binary_response" + fi + fi + ((attempt++)) + done fi # Upload source tarball @@ -434,8 +449,10 @@ create_gitea_release() { local release_id=$(echo "$check_response" | grep -o '"id":[0-9]*' | head -1 | cut -d':' -f2) print_status "Using existing release ID: $release_id" echo $release_id + else + print_error "Could not find existing release ID" + return 1 fi - echo 0 else print_error "Failed to create release $NEW_VERSION" print_error "Response: $response" @@ -449,7 +466,7 @@ create_gitea_release() { echo $release_id else print_error "Release does not exist and creation failed" - echo 1 + return 1 fi fi } @@ -510,12 +527,18 @@ main() { # Create Gitea release local release_id="" - if release_id=$(create_gitea_release 2>&1); then - # Upload assets if we have a release ID and assets - if [[ -n "$release_id" && (-n "$binary_path" || -n "$tarball_path") ]]; then - upload_release_assets "$release_id" "$binary_path" "$tarball_path" + if release_id=$(create_gitea_release); then + # Validate release_id is numeric + if [[ "$release_id" =~ ^[0-9]+$ ]]; then + # Upload assets if we have a release ID and assets + if [[ -n "$release_id" && (-n "$binary_path" || -n "$tarball_path") ]]; then + upload_release_assets "$release_id" "$binary_path" "$tarball_path" + fi + print_success "Release $NEW_VERSION completed successfully!" + else + print_error "Invalid release_id: $release_id" + exit 1 fi - print_success "Release $NEW_VERSION completed successfully!" else print_error "Release creation failed" fi