Use GitHub token in install.sh if available (#2676)
Some checks are pending
CI / lint (push) Waiting to run
CI / msrv (push) Waiting to run
CI / pages (push) Waiting to run
CI / test (macos-latest) (push) Waiting to run
CI / test (ubuntu-latest) (push) Waiting to run
CI / test (windows-latest) (push) Waiting to run

This commit is contained in:
Jeff Peeler 2025-07-05 17:33:33 -04:00 committed by GitHub
parent bfa5a6d99a
commit 33936f4918
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 7 deletions

View file

@ -392,6 +392,10 @@ to determine the latest version of `just` to install, and those API calls are
rate-limited on a per-IP basis. To make `install.sh` more reliable in such
circumstances, pass a specific tag to install with `--tag`.
Another way to avoid rate-limiting is to pass a GitHub authentication token to
`install.sh` as an environment variable named `GITHUB_TOKEN`, allowing it to
authenticate its requests.
[Releases](https://github.com/casey/just/releases) include a `SHA256SUM` file
which can be used to verify the integrity of pre-built binary archives.

View file

@ -1,11 +1,7 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
set -eu
if [ -n "${GITHUB_ACTIONS-}" ]; then
set -x
fi
# Check pipefail support in a subshell, ignore if unsupported
# shellcheck disable=SC3040
(set -o pipefail 2> /dev/null) && set -o pipefail
@ -55,10 +51,15 @@ download() {
url="$1"
output="$2"
args=()
if [ -n "${GITHUB_TOKEN+x}" ]; then
args+=(--header "Authorization: Bearer $GITHUB_TOKEN")
fi
if command -v curl > /dev/null; then
curl --proto =https --tlsv1.2 -sSfL "$url" "-o$output"
curl --proto =https --tlsv1.2 -sSfL ${args[@]+"${args[@]}"} "$url" -o"$output"
else
wget --https-only --secure-protocol=TLSv1_2 --quiet "$url" "-O$output"
wget --https-only --secure-protocol=TLSv1_2 --quiet ${args[@]+"${args[@]}"} "$url" -O"$output"
fi
}