Skip to content

Commit c565ca3

Browse files
authored
fix(install): resolve latest version via release redirect, not the rate-limited GitHub API (FIR-1012) (#43)
install.sh fetched the latest tag from api.github.com/releases/latest, whose ANONYMOUS rate limit is 60 req/hour per IP — trivially exhausted from a shared, NAT'd, corporate, or CI network, returning 403 -> 'Could not determine latest version'. Resolve the tag from the rate-limit-free `releases/latest` redirect (Location -> /releases/tag/vX.Y.Z) for both curl and wget. Surfaced by the install-proof (macos runner hit the API 403). Signed-off-by: Troy Fortin <troy@firelock.io>
1 parent 7a40b9a commit c565ca3

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

scripts/install.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,20 @@ if [ -n "${KIN_VERSION:-}" ]; then
8383
info "Version: $VERSION (pinned)"
8484
else
8585
info "Fetching latest version..."
86+
# Resolve the latest tag via the `releases/latest` REDIRECT
87+
# (Location -> .../releases/tag/vX.Y.Z) instead of api.github.com, whose
88+
# 60-requests/hour ANONYMOUS rate limit is trivially hit from a shared,
89+
# NAT'd, corporate, or CI IP and returns 403.
90+
LATEST_URL="https://github.com/$GITHUB_ORG/$GITHUB_REPO/releases/latest"
8691
if has_cmd curl; then
87-
VERSION=$(curl -fsSL "https://api.github.com/repos/$GITHUB_ORG/$GITHUB_REPO/releases/latest" | grep '"tag_name"' | sed 's/.*"v\(.*\)".*/\1/')
92+
RESOLVED=$(curl -fsSLI -o /dev/null -w '%{url_effective}' "$LATEST_URL")
8893
elif has_cmd wget; then
89-
VERSION=$(wget -qO- "https://api.github.com/repos/$GITHUB_ORG/$GITHUB_REPO/releases/latest" | grep '"tag_name"' | sed 's/.*"v\(.*\)".*/\1/')
94+
RESOLVED=$(wget -q -S -O /dev/null "$LATEST_URL" 2>&1 | sed -n 's/.*[Ll]ocation: *//p' | tail -1)
9095
else
9196
err "Neither curl nor wget found. Install one and retry."
9297
exit 1
9398
fi
99+
VERSION=$(printf '%s' "$RESOLVED" | sed -n 's#.*/releases/tag/v\([^/[:space:]]*\).*#\1#p')
94100

95101
if [ -z "$VERSION" ]; then
96102
err "Could not determine latest version. Set KIN_VERSION manually."

0 commit comments

Comments
 (0)