Skip to content

Agent Mesh

fix(install): resolve latest release via github.com redirect before API fallback

Antonio Ojea33fa7cfd887c
diff --git a/deploy/skypilot/sam-one.yaml b/deploy/skypilot/sam-one.yaml
index 0508ac05..a8bd65a5 100644
--- a/deploy/skypilot/sam-one.yaml
+++ b/deploy/skypilot/sam-one.yaml
@@ -39,7 +39,10 @@ setup: |
aarch64*|arm64*) ARCH_NAME="arm64" ;;
*) echo "Unsupported architecture: ${ARCH}" >&2; exit 1 ;;
esac
- VERSION=$(curl -fsSL "https://api.github.com/repos/google/sam/releases?per_page=1" | grep '"tag_name":' | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/')
+ VERSION=$(curl -fsSL -o /dev/null -w "%{url_effective}" "https://github.com/google/sam/releases/latest" | sed 's|.*/||')
+ if [[ -z "${VERSION}" || "${VERSION}" == "releases" ]]; then
+ VERSION=$(curl -fsSL "https://api.github.com/repos/google/sam/releases?per_page=1" | grep '"tag_name":' | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/')
+ fi
TMP_DIR=$(mktemp -d)
curl -fsSL -o "${TMP_DIR}/sam.tar.gz" "https://github.com/google/sam/releases/download/${VERSION}/sam_Linux_${ARCH_NAME}.tar.gz"
tar -xzf "${TMP_DIR}/sam.tar.gz" -C "${TMP_DIR}"
diff --git a/site/static/install.sh b/site/static/install.sh
index 20fc5e17..1ac57b1d 100755
--- a/site/static/install.sh
+++ b/site/static/install.sh
@@ -22,17 +22,14 @@ case "${ARCH}" in
*) echo "Unsupported architecture: ${ARCH}"; exit 1;;
esac
-# Get latest release version
+# Get latest release version via GitHub redirect (avoids api.github.com rate limits)
echo "Fetching latest release information..."
-LATEST_RELEASE_URL="https://api.github.com/repos/${REPO}/releases/latest"
-# `|| true`: with pipefail, a grep that matches nothing would kill the script
-# here instead of reaching the fallback/error below.
-VERSION=$(curl -s "$LATEST_RELEASE_URL" | grep '"tag_name":' | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/' || true)
-if [ -z "$VERSION" ]; then
- VERSION=$(curl -s "https://api.github.com/repos/${REPO}/releases?per_page=1" | grep '"tag_name":' | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/' || true)
+VERSION=$(curl -fsSL -o /dev/null -w "%{url_effective}" "https://github.com/${REPO}/releases/latest" | sed 's|.*/||' || true)
+if [ -z "$VERSION" ] || [ "$VERSION" = "releases" ]; then
+ VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases?per_page=1" | grep '"tag_name":' | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/' || true)
fi
-if [ -z "$VERSION" ]; then
+if [ -z "$VERSION" ] || [ "$VERSION" = "releases" ]; then
echo "Error: Could not find the latest release."
exit 1
fi