Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions scripts/ensure-basecamp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ install_basecamp() {
# Get platform
platform=$(detect_platform) || return 1

# Get latest version
version=$(curl -fsSL "https://api.github.com/repos/basecamp/basecamp-cli/releases/latest" 2>/dev/null | grep '"tag_name"' | sed -E 's/.*"v?([^"]+)".*/\1/')
if [[ -z "$version" ]]; then
# Get latest version via redirect (avoids GitHub API rate limits and grep/sed on Windows)
url=$(curl -fsSL -o /dev/null -w '%{url_effective}' "https://github.com/basecamp/basecamp-cli/releases/latest" 2>/dev/null) || true
version="${url##*/}"
version="${version#v}"
if [[ ! $version =~ ^[0-9]+\.[0-9]+ ]]; then
Comment thread
jeremy marked this conversation as resolved.
echo "Could not determine latest version" >&2
return 1
fi
Expand Down
10 changes: 7 additions & 3 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ detect_platform() {
}

get_latest_version() {
local version
version=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" 2>/dev/null | grep '"tag_name"' | sed -E 's/.*"v?([^"]+)".*/\1/')
if [[ -z "$version" ]]; then
local url version
# Follow the releases/latest redirect to get the version from the final URL.
# Avoids the GitHub API (no rate limiting) and grep/sed (better Windows compat).
url=$(curl -fsSL -o /dev/null -w '%{url_effective}' "https://github.com/${REPO}/releases/latest" 2>/dev/null) || true
Comment thread
jeremy marked this conversation as resolved.
version="${url##*/}"
version="${version#v}"
if [[ ! $version =~ ^[0-9]+\.[0-9]+ ]]; then
Comment thread
jeremy marked this conversation as resolved.
error "Could not determine latest version. Check your network connection."
fi
echo "$version"
Expand Down
Loading