Skip to content

Commit 33fa7cf

Browse files
committed
fix(install): resolve latest release via github.com redirect before API fallback
1 parent 4479a97 commit 33fa7cf

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎deploy/skypilot/sam-one.yaml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ setup: |
3939
aarch64*|arm64*) ARCH_NAME="arm64" ;;
4040
*) echo "Unsupported architecture: ${ARCH}" >&2; exit 1 ;;
4141
esac
42-
VERSION=$(curl -fsSL "https://api.github.com/repos/google/sam/releases?per_page=1" | grep '"tag_name":' | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/')
42+
VERSION=$(curl -fsSL -o /dev/null -w "%{url_effective}" "https://github.com/google/sam/releases/latest" | sed 's|.*/||')
43+
if [[ -z "${VERSION}" || "${VERSION}" == "releases" ]]; then
44+
VERSION=$(curl -fsSL "https://api.github.com/repos/google/sam/releases?per_page=1" | grep '"tag_name":' | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/')
45+
fi
4346
TMP_DIR=$(mktemp -d)
4447
curl -fsSL -o "${TMP_DIR}/sam.tar.gz" "https://github.com/google/sam/releases/download/${VERSION}/sam_Linux_${ARCH_NAME}.tar.gz"
4548
tar -xzf "${TMP_DIR}/sam.tar.gz" -C "${TMP_DIR}"

‎site/static/install.sh‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,14 @@ case "${ARCH}" in
2222
*) echo "Unsupported architecture: ${ARCH}"; exit 1;;
2323
esac
2424

25-
# Get latest release version
25+
# Get latest release version via GitHub redirect (avoids api.github.com rate limits)
2626
echo "Fetching latest release information..."
27-
LATEST_RELEASE_URL="https://api.github.com/repos/${REPO}/releases/latest"
28-
# `|| true`: with pipefail, a grep that matches nothing would kill the script
29-
# here instead of reaching the fallback/error below.
30-
VERSION=$(curl -s "$LATEST_RELEASE_URL" | grep '"tag_name":' | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/' || true)
31-
if [ -z "$VERSION" ]; then
32-
VERSION=$(curl -s "https://api.github.com/repos/${REPO}/releases?per_page=1" | grep '"tag_name":' | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/' || true)
27+
VERSION=$(curl -fsSL -o /dev/null -w "%{url_effective}" "https://github.com/${REPO}/releases/latest" | sed 's|.*/||' || true)
28+
if [ -z "$VERSION" ] || [ "$VERSION" = "releases" ]; then
29+
VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases?per_page=1" | grep '"tag_name":' | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/' || true)
3330
fi
3431

35-
if [ -z "$VERSION" ]; then
32+
if [ -z "$VERSION" ] || [ "$VERSION" = "releases" ]; then
3633
echo "Error: Could not find the latest release."
3734
exit 1
3835
fi

0 commit comments

Comments
 (0)