From c0eb6659f2373eac3e2d9c0c8cbce1edd82a71ad Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Fri, 1 Aug 2025 12:57:48 +0300 Subject: [PATCH 1/2] fix: try to fix CI failures on macOS --- lib/utils.bash | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/utils.bash b/lib/utils.bash index cc716cb..6d536c8 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -46,9 +46,21 @@ sort_versions() { } fetch_all_assets() { - curl -s -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${GH_REPO}/releases | - jq -r '.[0].assets[] | "\(.name) \(.browser_download_url)"' + local attempts=0 + local releases_json + while [ $attempts -lt 5 ]; do + releases_json="$(curl -s -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${GH_REPO}/releases)" + if echo "$releases_json" | jq -e 'type == "array"' >/dev/null; then + echo "$releases_json" | jq -r '.[0].assets[] | "\(.name) \(.browser_download_url)"' + return 0 + fi + log "Failed to fetch releases (attempt $((attempts+1))). Retrying in 2s..." + sleep 2 + attempts=$((attempts+1)) + done + echo "$releases_json" | jq '.' # Print last error + fail "GitHub API did not return a valid releases array after $attempts attempts." } validate_platform() { From a6a9d19e09fb4fb88bbaaad379f6c70d46f3d618 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Fri, 1 Aug 2025 13:00:46 +0300 Subject: [PATCH 2/2] Update utils.bash --- lib/utils.bash | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/utils.bash b/lib/utils.bash index 6d536c8..05e434c 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -46,21 +46,17 @@ sort_versions() { } fetch_all_assets() { - local attempts=0 local releases_json - while [ $attempts -lt 5 ]; do - releases_json="$(curl -s -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${GH_REPO}/releases)" - if echo "$releases_json" | jq -e 'type == "array"' >/dev/null; then - echo "$releases_json" | jq -r '.[0].assets[] | "\(.name) \(.browser_download_url)"' - return 0 - fi - log "Failed to fetch releases (attempt $((attempts+1))). Retrying in 2s..." - sleep 2 - attempts=$((attempts+1)) - done - echo "$releases_json" | jq '.' # Print last error - fail "GitHub API did not return a valid releases array after $attempts attempts." + releases_json="$(curl -s -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${GH_REPO}/releases)" + + # Validate that the response is an array (successful), otherwise print and fail + if ! echo "$releases_json" | jq -e 'type == "array"' >/dev/null; then + echo "$releases_json" | jq '.' # Optionally print error for debugging + fail "GitHub API did not return a valid releases array - likely rate-limited or network error." + fi + + echo "$releases_json" | jq -r '.[0].assets[] | "\(.name) \(.browser_download_url)"' } validate_platform() {