diff --git a/bin/install-latest-linux.sh b/bin/install-latest-linux.sh index da516c9ae..5c23fb9e8 100755 --- a/bin/install-latest-linux.sh +++ b/bin/install-latest-linux.sh @@ -2,7 +2,27 @@ set -eo pipefail # Install the latest version of the Linux binary -DOWNLOAD_URL="$(curl -s https://api.github.com/repos/brevdev/brev-cli/releases/latest | grep "browser_download_url.*linux.*amd64" | cut -d '"' -f 4)" +API_RESPONSE="$(curl -s https://api.github.com/repos/brevdev/brev-cli/releases/latest)" + +# Check for GitHub API rate limit error +if echo "${API_RESPONSE}" | grep -q "API rate limit exceeded"; then + echo "Error: GitHub API rate limit exceeded." >&2 + echo "" >&2 + echo "This often happens when many requests come from the same IP address." >&2 + echo "If you are using a VPN, try turning it off and running this script again." >&2 + echo "" >&2 + echo "For more details, see: https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting" >&2 + exit 1 +fi + +DOWNLOAD_URL="$(echo "${API_RESPONSE}" | grep "browser_download_url.*linux.*amd64" | cut -d '"' -f 4)" + +if [ -z "${DOWNLOAD_URL}" ]; then + echo "Error: Could not find release for linux amd64" >&2 + echo "GitHub API response:" >&2 + echo "${API_RESPONSE}" >&2 + exit 1 +fi # Create temporary directory and ensure cleanup TMP_DIR="$(mktemp -d)" diff --git a/bin/install-latest.sh b/bin/install-latest.sh index 16f5c6343..29328f9ec 100755 --- a/bin/install-latest.sh +++ b/bin/install-latest.sh @@ -10,11 +10,26 @@ case "${ARCH}" in esac # Get the appropriate download URL for this platform -DOWNLOAD_URL="$(curl -s https://api.github.com/repos/brevdev/brev-cli/releases/latest | grep "browser_download_url.*${OS}.*${ARCH}" | cut -d '"' -f 4)" +API_RESPONSE="$(curl -s https://api.github.com/repos/brevdev/brev-cli/releases/latest)" + +# Check for GitHub API rate limit error +if echo "${API_RESPONSE}" | grep -q "API rate limit exceeded"; then + echo "Error: GitHub API rate limit exceeded." >&2 + echo "" >&2 + echo "This often happens when many requests come from the same IP address." >&2 + echo "If you are using a VPN, try turning it off and running this script again." >&2 + echo "" >&2 + echo "For more details, see: https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting" >&2 + exit 1 +fi + +DOWNLOAD_URL="$(echo "${API_RESPONSE}" | grep "browser_download_url.*${OS}.*${ARCH}" | cut -d '"' -f 4)" # Verify we found a suitable release if [ -z "${DOWNLOAD_URL}" ]; then echo "Error: Could not find release for ${OS} ${ARCH}" >&2 + echo "GitHub API response:" >&2 + echo "${API_RESPONSE}" >&2 exit 1 fi diff --git a/scripts/install-agent-skill.sh b/scripts/install-agent-skill.sh index e8597c2e3..5f73f1e0b 100755 --- a/scripts/install-agent-skill.sh +++ b/scripts/install-agent-skill.sh @@ -116,12 +116,21 @@ done rm -rf "$TMPDIR" # Resolve commit SHA and write .version file -COMMIT_SHA=$(curl -fsSL "https://api.github.com/repos/$REPO/commits/$BRANCH" 2>/dev/null | grep '"sha"' | head -1 | sed 's/.*"sha": *"\([^"]*\)".*/\1/') -if [[ -n "$COMMIT_SHA" ]]; then - for dir in "${INSTALL_DIRS[@]}"; do - printf 'branch=%s\ncommit=%s\n' "$BRANCH" "$COMMIT_SHA" > "$dir/.version" - done - echo -e " ${GREEN}✓${NC} .version (${COMMIT_SHA:0:12})" +VERSION_RESPONSE=$(curl -fsSL "https://api.github.com/repos/$REPO/commits/$BRANCH" 2>&1) || true +if echo "$VERSION_RESPONSE" | grep -q "API rate limit exceeded"; then + echo -e " ${YELLOW}⚠${NC} .version (skipped — GitHub API rate limit exceeded)" + echo -e " ${YELLOW}If you are using a VPN, try turning it off and running this script again.${NC}" + echo -e " ${YELLOW}See: https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting${NC}" +else + COMMIT_SHA=$(echo "$VERSION_RESPONSE" | grep '"sha"' | head -1 | sed 's/.*"sha": *"\([^"]*\)".*/\1/') + if [[ -n "$COMMIT_SHA" ]]; then + for dir in "${INSTALL_DIRS[@]}"; do + printf 'branch=%s\ncommit=%s\n' "$BRANCH" "$COMMIT_SHA" > "$dir/.version" + done + echo -e " ${GREEN}✓${NC} .version (${COMMIT_SHA:0:12})" + else + echo -e " ${YELLOW}⚠${NC} .version (could not resolve commit SHA)" + fi fi echo ""