mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 21:48:42 +00:00

* Fix installer downloads for specific releases Github download urls for a specific release uses the pattern `../releases/download/[RELEASE]/..`, which differs from the latest release URL which uses `../releases/latest/download/..`. For convenience, if `BINSTALL_VERSION` is set but doesn't start with `v`, the v is prefixed. * ci: Set BINSTALL_VERSION in install script tests When running the install-script workflow in Github Actions, add matrix options for not setting the variable, setting it to the latest release with the `v` prefix, and setting it to the latest release without the `v` prefix.
61 lines
2.1 KiB
Bash
Executable file
61 lines
2.1 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
set -euxo pipefail
|
|
|
|
if [[ -n "${BINSTALL_VERSION:-}" && "$BINSTALL_VERSION" != v* ]]; then
|
|
# prefix version with v
|
|
BINSTALL_VERSION="v$BINSTALL_VERSION"
|
|
fi
|
|
|
|
cd "$(mktemp -d)"
|
|
|
|
# Fetch binaries from `[..]/releases/latest/download/[..]` if _no_ version is
|
|
# given, otherwise from `[..]/releases/download/VERSION/[..]`. Note the shifted
|
|
# location of '/download'.
|
|
if [[ -z "${BINSTALL_VERSION:-}" ]]; then
|
|
base_url="https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-"
|
|
else
|
|
base_url="https://github.com/cargo-bins/cargo-binstall/releases/download/${BINSTALL_VERSION}/cargo-binstall-"
|
|
fi
|
|
|
|
os="$(uname -s)"
|
|
if [ "$os" == "Darwin" ]; then
|
|
url="${base_url}universal-apple-darwin.zip"
|
|
curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -LO --proto '=https' --tlsv1.2 -sSf "$url"
|
|
unzip cargo-binstall-universal-apple-darwin.zip
|
|
elif [ "$os" == "Linux" ]; then
|
|
machine="$(uname -m)"
|
|
if [ "$machine" == "armv7l" ]; then
|
|
machine="armv7"
|
|
fi
|
|
target="${machine}-unknown-linux-musl"
|
|
if [ "$machine" == "armv7" ]; then
|
|
target="${target}eabihf"
|
|
fi
|
|
|
|
url="${base_url}${target}.tgz"
|
|
curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -L --proto '=https' --tlsv1.2 -sSf "$url" | tar -xvzf -
|
|
elif [ "${OS-}" = "Windows_NT" ]; then
|
|
machine="$(uname -m)"
|
|
target="${machine}-pc-windows-msvc"
|
|
url="${base_url}${target}.zip"
|
|
curl -A "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/81.0" -LO --proto '=https' --tlsv1.2 -sSf "$url"
|
|
unzip "cargo-binstall-${target}.zip"
|
|
else
|
|
echo "Unsupported OS ${os}"
|
|
exit 1
|
|
fi
|
|
|
|
./cargo-binstall --self-install || ./cargo-binstall -y --force cargo-binstall
|
|
|
|
CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
|
|
|
|
if ! [[ ":$PATH:" == *":$CARGO_HOME/bin:"* ]]; then
|
|
if [ -n "${CI:-}" ] && [ -n "${GITHUB_PATH:-}" ]; then
|
|
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
|
|
else
|
|
echo
|
|
printf "\033[0;31mYour path is missing %s, you might want to add it.\033[0m\n" "$CARGO_HOME/bin"
|
|
echo
|
|
fi
|
|
fi
|