Skip to content

Commit 23f9ffa

Browse files
committed
fix: resolve latest release tag from GitHub API in installer
1 parent 679f860 commit 23f9ffa

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

install.sh

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,29 @@ command -v uv >/dev/null 2>&1 || {
3737
}
3838
UV_BIN="$(command -v uv)"
3939

40-
# 2. resolve the release tag (follow the /releases/latest redirect; no jq needed)
40+
# 2. resolve the release tag (GitHub API is used first; fallback keeps old behaviour).
4141
if [ "$VERSION" = "latest" ]; then
42-
url=$(curl -fsSLI -o /dev/null -w '%{url_effective}' \
43-
"https://github.com/$REPO/releases/latest") || {
42+
api_response="$(mktemp)"
43+
if ! curl -fsSL \
44+
-H "Accept: application/vnd.github+json" \
45+
-H "User-Agent: git-auto-sync-installer" \
46+
"https://api.github.com/repos/$REPO/releases/latest" \
47+
-o "$api_response"; then
48+
rm -f "$api_response"
4449
err "Couldn't reach GitHub to resolve the latest release."
4550
exit 1
46-
}
47-
TAG="${url##*/}"
51+
fi
52+
TAG="$(sed -n 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\\([^"]*\\)".*/\\1/p' "$api_response" | head -n 1)"
53+
rm -f "$api_response"
54+
if [ -z "$TAG" ] || [ "${TAG#v}" = "$TAG" ]; then
55+
info "GitHub API did not return a release tag, falling back to web redirect resolution."
56+
url="$(curl -fsSLI -o /dev/null -w '%{url_effective}' \
57+
"https://github.com/$REPO/releases/latest")" || {
58+
err "Couldn't resolve the latest release."
59+
exit 1
60+
}
61+
TAG="${url##*/}"
62+
fi
4863
else
4964
TAG="$VERSION"
5065
fi

0 commit comments

Comments
 (0)