mirror of
https://github.com/taiki-e/install-action.git
synced 2026-04-21 15:10:27 +00:00
Use --arg for jq more
This commit is contained in:
12
main.sh
12
main.sh
@@ -277,14 +277,14 @@ read_manifest() {
|
||||
# usually preferred over linux-gnu binaries because they can avoid glibc version issues.
|
||||
# (rustc enables statically linking for linux-musl by default, except for mips.)
|
||||
host_platform="${host_arch}_linux_musl"
|
||||
download_info=$(jq -r ".${host_platform}" <<<"${manifest}")
|
||||
download_info=$(jq -r --arg p "${host_platform}" '.[$p]' <<<"${manifest}")
|
||||
if [[ "${download_info}" == "null" ]]; then
|
||||
# Even if host_env is musl, we won't issue an error here because it seems that in
|
||||
# some cases linux-gnu binaries will work on linux-musl hosts.
|
||||
# https://wiki.alpinelinux.org/wiki/Running_glibc_programs
|
||||
# TODO: However, a warning may make sense.
|
||||
host_platform="${host_arch}_linux_gnu"
|
||||
download_info=$(jq -r ".${host_platform}" <<<"${manifest}")
|
||||
download_info=$(jq -r --arg p "${host_platform}" '.[$p]' <<<"${manifest}")
|
||||
elif [[ "${host_env}" == "gnu" ]]; then
|
||||
# TODO: don't hardcode tool name and use 'prefer_linux_gnu' field in base manifest.
|
||||
case "${tool}" in
|
||||
@@ -296,7 +296,7 @@ read_manifest() {
|
||||
# musl build of nextest is slow, so use glibc build if host_env is gnu.
|
||||
# https://github.com/taiki-e/install-action/issues/13
|
||||
host_platform="${host_arch}_linux_gnu"
|
||||
download_info=$(jq -r ".${host_platform}" <<<"${manifest}")
|
||||
download_info=$(jq -r --arg p "${host_platform}" '.[$p]' <<<"${manifest}")
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
@@ -306,10 +306,10 @@ read_manifest() {
|
||||
# Binaries compiled for x86_64 macOS will usually also work on AArch64 macOS.
|
||||
# Binaries compiled for x86_64 Windows will usually also work on AArch64 Windows 11+.
|
||||
host_platform="${host_arch}_${host_os}"
|
||||
download_info=$(jq -r ".${host_platform}" <<<"${manifest}")
|
||||
download_info=$(jq -r --arg p "${host_platform}" '.[$p]' <<<"${manifest}")
|
||||
if [[ "${download_info}" == "null" ]] && [[ "${host_arch}" != "x86_64" ]]; then
|
||||
host_platform="x86_64_${host_os}"
|
||||
download_info=$(jq -r ".${host_platform}" <<<"${manifest}")
|
||||
download_info=$(jq -r --arg p "${host_platform}" '.[$p]' <<<"${manifest}")
|
||||
fi
|
||||
;;
|
||||
*) bail "unsupported OS type '${host_os}' for ${tool}" ;;
|
||||
@@ -327,7 +327,7 @@ read_download_info() {
|
||||
bin_in_archive=()
|
||||
if [[ "${url}" == "null" ]]; then
|
||||
local template
|
||||
template=$(jq -c ".template.${host_platform}" "${manifest_dir}/${tool}.json")
|
||||
template=$(jq -c --arg p "${host_platform}" '.template[$p]' "${manifest_dir}/${tool}.json")
|
||||
template="${template//\$\{version\}/${exact_version}}"
|
||||
url=$(jq -r '.url' <<<"${template}")
|
||||
tmp=$(jq -r '.bin' <<<"${template}")
|
||||
|
||||
@@ -147,12 +147,12 @@ for manifest in tools/codegen/base/*.json; do
|
||||
fi
|
||||
case "${host_os}" in
|
||||
linux*)
|
||||
if [[ "${host_arch}" != "x86_64" ]] && [[ "$(jq -r ".platform.${host_arch}_${host_os}_gnu" "${manifest}")" == "null" ]] && [[ "$(jq -r ".platform.${host_arch}_${host_os}_musl" "${manifest}")" == "null" ]]; then
|
||||
if [[ "${host_arch}" != "x86_64" ]] && [[ "$(jq -r --arg p "${host_arch}_${host_os}_gnu" '.platform[$p]' "${manifest}")" == "null" ]] && [[ "$(jq -r --arg p "${host_arch}_${host_os}_musl" '.platform[$p]' "${manifest}")" == "null" ]]; then
|
||||
continue
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [[ "$(jq -r ".platform.x86_64_${host_os}" "${manifest}")" == "null" ]] && [[ "$(jq -r ".platform.${host_arch}_${host_os}" "${manifest}")" == "null" ]]; then
|
||||
if [[ "$(jq -r --arg p "x86_64_${host_os}" '.platform[$p]' "${manifest}")" == "null" ]] && [[ "$(jq -r --arg p "${host_arch}_${host_os}" '.platform[$p]' "${manifest}")" == "null" ]]; then
|
||||
continue
|
||||
fi
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user