@@ -12,36 +12,24 @@ ASSET="$BIN-$OS-$ARCH"
1212
1313# 2) Resolve release tag
1414#
15- # When 100s of attendees install at the same hackathon they share one
16- # public IP and would burn through GitHub's 60/hour anonymous-IP API
17- # quota almost immediately. Both resolution paths below are NOT
18- # `api.github.com` so neither contributes to that quota:
19- #
20- # a) jsDelivr's /resolved endpoint mirrors GitHub releases via a CDN
21- # — same source `dot update` uses for the version-check banner.
22- # Response shape: `{ "version": "0.17.0" }`.
23- # b) github.com redirect probe — GitHub redirects
24- # `releases/latest` → `releases/tag/vX.Y.Z`; we read the tag from
25- # the `Location:` header. No body, no API call.
26- #
27- # We try jsDelivr first because we already trust it from `dot update`.
28- # The github.com redirect is the fallback for the rare case jsDelivr
29- # is briefly unreachable. There is intentionally NO `api.github.com`
30- # fallback any more.
15+ # Use VERSION to install a specific tag. Otherwise, prefer GitHub's no-body
16+ # `releases/latest` redirect. This avoids api.github.com quota while keeping
17+ # "latest" tied to the same GitHub release source used for the binary
18+ # download. jsDelivr is CDN-backed and can lag a freshly published release,
19+ # so keep it as fallback only.
3120if [ -n " $VERSION " ]; then
3221 TAG=" $VERSION "
3322else
34- TAG=$( curl -fsSL " https://data.jsdelivr.com/v1/packages/gh/$REPO /resolved" \
35- | sed -n ' s/.*"version": *"\([^"]*\)".*/\1/p' | head -n1) || true
36- # jsDelivr returns the version without the leading `v`, but our release
37- # tags are `vX.Y.Z`. Normalise so step (3) below builds the right URL.
38- case " $TAG " in v* ) ;; ' ' ) ;; * ) TAG=" v$TAG " ;; esac
23+ TAG=$( curl -fsSI -H " Cache-Control: no-cache" -H " Pragma: no-cache" " https://github.com/$REPO /releases/latest" \
24+ | sed -n ' s|^[Ll][Oo][Cc][Aa][Tt][Ii][Oo][Nn]:[[:space:]]*.*/tag/\(.*\)$|\1|p' \
25+ | tr -d ' \r' | head -n1) || true
3926 if [ -z " $TAG " ]; then
40- TAG=$( curl -fsSI " https://github. com/$REPO /releases/latest " \
41- | sed -n ' s|^location:.*/tag/\(. *\)$|\1|p ' | tr -d ' \r ' | head -n1) || true
27+ TAG=$( curl -fsSL " https://data.jsdelivr. com/v1/packages/gh/ $REPO /resolved " \
28+ | sed -n ' s/.*"version": *"\([^"] *\)".*/\1/p ' | head -n1) || true
4229 fi
4330fi
4431[ -z " $TAG " ] && echo " Could not determine latest release" && exit 1
32+ case " $TAG " in v* ) ;; * ) TAG=" v$TAG " ;; esac
4533
4634# 3) Install binary
4735spin () { while true ; do for c in ' |' ' /' ' -' ' \' ; do printf " \r%s %s" " $1 " " $c " ; sleep 0.1; done ; done ; }
0 commit comments