mirror of
https://github.com/taiki-e/install-action.git
synced 2026-04-20 20:22:36 +08:00
Use cargo-binstall as fallback in main.sh (#8)
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
@@ -26,19 +26,20 @@ jobs:
|
||||
- ubuntu-20.04
|
||||
tool:
|
||||
# Note: Specifying the version of valgrind and wasm-pack is not supported.
|
||||
- cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,shellcheck,shfmt,valgrind,wasm-pack,wasmtime,mdbook
|
||||
- cargo-hack@0.5.14,cargo-llvm-cov@0.4.5,cargo-minimal-versions@0.1.4,parse-changelog@0.4.8,cross@0.2.1,nextest@0.9.11,shellcheck@0.8.0,shfmt@3.5.0,wasmtime@0.37.0,mdbook@0.4.18
|
||||
# cargo-watch is supported by cargo-binstall (through quickinstall)
|
||||
- cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,shellcheck,shfmt,valgrind,wasm-pack,wasmtime,mdbook,cargo-watch
|
||||
- cargo-hack@0.5.14,cargo-llvm-cov@0.4.5,cargo-minimal-versions@0.1.4,parse-changelog@0.4.8,cross@0.2.1,nextest@0.9.11,shellcheck@0.8.0,shfmt@3.5.0,wasmtime@0.37.0,mdbook@0.4.18,cargo-watch@8.1.1
|
||||
# Nextest supports basic version ranges as well
|
||||
- nextest@0.9
|
||||
include:
|
||||
# Note: mdBook binary is incompatible with ubuntu 18.04,
|
||||
# see https://github.com/rust-lang/mdBook/issues/1779
|
||||
- os: ubuntu-18.04
|
||||
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,shellcheck,shfmt,valgrind,wasm-pack,wasmtime
|
||||
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,shellcheck,shfmt,valgrind,wasm-pack,wasmtime,cargo-watch
|
||||
- os: macos-10.15
|
||||
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,shellcheck,shfmt,wasm-pack,wasmtime,mdbook
|
||||
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,shellcheck,shfmt,wasm-pack,wasmtime,mdbook,cargo-watch
|
||||
- os: windows-2019
|
||||
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest
|
||||
tool: cargo-hack,cargo-llvm-cov,cargo-minimal-versions,parse-changelog,cross,nextest,cargo-watch
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
77
main.sh
77
main.sh
@@ -30,6 +30,73 @@ warn() {
|
||||
info() {
|
||||
echo "info: $*"
|
||||
}
|
||||
install_cargo_binstall() {
|
||||
cargo_bin="${CARGO_HOME:-$HOME/.cargo}/bin"
|
||||
|
||||
if [ ! -f "${cargo_bin}/cargo-binstall" ]; then
|
||||
info "installing cargo-binstall"
|
||||
|
||||
target="$(rustc -vV | grep host | cut -c 7-)"
|
||||
base_url=https://github.com/ryankurte/cargo-binstall/releases/latest/download/cargo-binstall
|
||||
is_zip=false
|
||||
case "${target}" in
|
||||
x86_64-unknown-linux-gnu) url="${base_url}-x86_64-unknown-linux-musl.tgz" ;;
|
||||
x86_64-unknown-linux-musl) url="${base_url}-x86_64-unknown-linux-musl.tgz" ;;
|
||||
|
||||
armv7-unknown-linux-gnueabihf) url="${base_url}-armv7-unknown-linux-musleabihf.tgz" ;;
|
||||
armv7-unknown-linux-musleabihf) url="${base_url}-armv7-unknown-linux-musleabihf.tgz" ;;
|
||||
|
||||
aarch64-unknown-linux-gnu) url="${base_url}-aarch64-unknown-linux-musl.tgz" ;;
|
||||
aarch64-unknown-linux-musl) url="${base_url}-aarch64-unknown-linux-musl.tgz" ;;
|
||||
|
||||
x86_64-pc-windows-gnu)
|
||||
is_zip=true
|
||||
url="${base_url}-x86_64-pc-windows-msvc.zip"
|
||||
;;
|
||||
|
||||
x86_64-apple-darwin | aarch64-apple-darwin | x86_64-pc-windows-msvc)
|
||||
is_zip=true
|
||||
url="${base_url}-${target}.zip"
|
||||
;;
|
||||
|
||||
*) bail "unsupported target '${target}' for cargo-binstall" ;;
|
||||
esac
|
||||
|
||||
if [ $is_zip = true ]; then
|
||||
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "$url" -o "cargo-binstall-${target}.zip"
|
||||
unzip "cargo-binstall-${target}.zip"
|
||||
rm "cargo-binstall-${target}.zip"
|
||||
else
|
||||
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "$url" | tar xzf -
|
||||
fi
|
||||
|
||||
mkdir -p "{cargo_bin}/"
|
||||
|
||||
case "${OSTYPE}" in
|
||||
cygwin* | msys*) mv cargo-binstall.exe "${cargo_bin}/" ;;
|
||||
*) mv cargo-binstall "${cargo_bin}/" ;;
|
||||
esac
|
||||
else
|
||||
info "cargo-binstall already installed on in ${cargo_bin}/cargo-binstall"
|
||||
fi
|
||||
}
|
||||
cargo_binstall() {
|
||||
tool="$1"
|
||||
version="$2"
|
||||
|
||||
info "install-action does not support ${tool}, fallback to cargo-binstall"
|
||||
|
||||
install_cargo_binstall
|
||||
|
||||
case "${version}" in
|
||||
latest)
|
||||
cargo binstall --no-confirm "$tool"
|
||||
;;
|
||||
*)
|
||||
cargo binstall --no-confirm --version "$version" "$tool"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [[ $# -gt 0 ]]; then
|
||||
bail "invalid argument '$1'"
|
||||
@@ -213,13 +280,7 @@ for tool in "${tools[@]}"; do
|
||||
retry curl --proto '=https' --tlsv1.2 -fsSL --retry 10 --retry-connrefused "${url}" \
|
||||
| tar xzf - -C ${CARGO_HOME:-~/.cargo}/bin
|
||||
;;
|
||||
*) bail "unsupported tool '${tool}'" ;;
|
||||
cargo-binstall) install_cargo_binstall ;;
|
||||
*) cargo_binstall "$tool" "$version" ;;
|
||||
esac
|
||||
|
||||
info "${tool} installed at $(type -P "${tool}")"
|
||||
case "${tool}" in
|
||||
cargo-* | nextest) x cargo "${tool#cargo-}" --version ;;
|
||||
*) x "${tool}" --version ;;
|
||||
esac
|
||||
echo
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user