mirror of
https://github.com/taiki-e/install-action.git
synced 2026-05-09 14:20:29 +00:00
Use cargo-binstall fallback also if tool is available but specified version not available
This commit is contained in:
@@ -20,6 +20,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
|
||||
|
||||
- Fix install failure of Rust-related binaries when `$CARGO_HOME/bin` exists, but is not included in the `$PATH`. This failure occurred in slightly odd cases, such as multiple installations of rust in different directories.
|
||||
|
||||
- Use cargo-binstall fallback also if tool is available but the specified version not available. ([#68](https://github.com/taiki-e/install-action/pull/68))
|
||||
|
||||
## [2.3.5] - 2023-02-04
|
||||
|
||||
- Update `cross@latest` to 0.2.5.
|
||||
|
||||
28
main.sh
28
main.sh
@@ -137,17 +137,15 @@ read_manifest() {
|
||||
local manifest
|
||||
manifest=$(jq -r ".\"${version}\"" "${manifest_dir}/${tool}.json")
|
||||
if [[ "${manifest}" == "null" ]]; then
|
||||
bail "version '${version}' for ${tool} is not supported"
|
||||
download_info="null"
|
||||
return 0
|
||||
fi
|
||||
local exact_version
|
||||
exact_version=$(jq <<<"${manifest}" -r '.version')
|
||||
if [[ "${exact_version}" == "null" ]]; then
|
||||
exact_version="${version}"
|
||||
else
|
||||
manifest=$(jq -r ".\"${exact_version}\"" "${manifest_dir}/${tool}.json")
|
||||
fi
|
||||
local download_info
|
||||
local host_platform
|
||||
case "${host_os}" in
|
||||
linux)
|
||||
# Static-linked binaries compiled for linux-musl will also work on linux-gnu systems and are
|
||||
@@ -191,6 +189,10 @@ read_manifest() {
|
||||
;;
|
||||
*) bail "unsupported OS type '${host_os}' for ${tool}" ;;
|
||||
esac
|
||||
}
|
||||
read_download_info() {
|
||||
local tool="$1"
|
||||
local version="$2"
|
||||
if [[ "${download_info}" == "null" ]]; then
|
||||
bail "${tool}@${version} for '${host_os}' is not supported"
|
||||
fi
|
||||
@@ -218,6 +220,10 @@ read_manifest() {
|
||||
}
|
||||
download_from_manifest() {
|
||||
read_manifest "$@"
|
||||
download_from_download_info "$@"
|
||||
}
|
||||
download_from_download_info() {
|
||||
read_download_info "$@"
|
||||
download_and_extract "${url}" "${checksum}" "${bin_dir}" "${bin_in_archive}"
|
||||
}
|
||||
install_cargo_binstall() {
|
||||
@@ -441,6 +447,7 @@ for tool in "${tools[@]}"; do
|
||||
protoc)
|
||||
info "installing ${tool}@${version}"
|
||||
read_manifest "protoc" "${version}"
|
||||
read_download_info "protoc" "${version}"
|
||||
# Copying files to /usr/local/include requires sudo, so do not use it.
|
||||
bin_dir="${HOME}/.install-action/bin"
|
||||
include_dir="${HOME}/.install-action/include"
|
||||
@@ -513,6 +520,17 @@ for tool in "${tools[@]}"; do
|
||||
continue
|
||||
fi
|
||||
|
||||
# Use cargo-binstall fallback if tool is available but the specified version not available.
|
||||
read_manifest "${tool}" "${version}"
|
||||
if [[ "${download_info}" == "null" ]]; then
|
||||
warn "${tool}@${version} for '${host_os}' is not supported; fallback to cargo-binstall"
|
||||
case "${version}" in
|
||||
latest) unsupported_tools+=("${tool}") ;;
|
||||
*) unsupported_tools+=("${tool}@${version}") ;;
|
||||
esac
|
||||
continue
|
||||
fi
|
||||
|
||||
info "installing ${tool}@${version}"
|
||||
|
||||
# Pre-install
|
||||
@@ -528,7 +546,7 @@ for tool in "${tools[@]}"; do
|
||||
;;
|
||||
esac
|
||||
|
||||
download_from_manifest "${tool}" "${version}"
|
||||
download_from_download_info "${tool}" "${version}"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
Reference in New Issue
Block a user