Format shell scripts with indent_size = 2 to match scripts in CI config

This commit is contained in:
Taiki Endo
2025-01-17 16:44:56 +09:00
parent 1b8d452217
commit 9469185794
7 changed files with 1308 additions and 1308 deletions

View File

@@ -6,12 +6,12 @@ trap -- 's=$?; printf >&2 "%s\n" "${0##*/}:${LINENO}: \`${BASH_COMMAND}\` exit w
cd -- "$(dirname -- "$0")"/../..
bail() {
printf >&2 'error: %s\n' "$*"
exit 1
printf >&2 'error: %s\n' "$*"
exit 1
}
if [[ -z "${CI:-}" ]]; then
bail "this script is intended to call from release workflow on CI"
bail "this script is intended to call from release workflow on CI"
fi
git config user.name 'Taiki Endo'
@@ -21,28 +21,28 @@ set -x
has_update=''
for manifest in manifests/*.json; do
git add -N "${manifest}"
if ! git diff --exit-code -- "${manifest}"; then
name="${manifest##*/}"
name="${name%.*}"
git stash
old_version=$(jq -r '.latest.version' "${manifest}")
git stash pop
new_version=$(jq -r '.latest.version' "${manifest}")
if [[ "${old_version}" != "${new_version}" ]]; then
# TODO: If there is a line about updating the same tool in the "Unreleased" section, replace it.
msg="Update \`${name}@latest\` to ${new_version}"
sed -Ei "s/^## \\[Unreleased\\]/## [Unreleased]\\n\\n- ${msg}./" CHANGELOG.md
git add "${manifest}" CHANGELOG.md
else
msg="Update ${name} manifest"
git add "${manifest}"
fi
git commit -m "${msg}"
has_update=1
git add -N "${manifest}"
if ! git diff --exit-code -- "${manifest}"; then
name="${manifest##*/}"
name="${name%.*}"
git stash
old_version=$(jq -r '.latest.version' "${manifest}")
git stash pop
new_version=$(jq -r '.latest.version' "${manifest}")
if [[ "${old_version}" != "${new_version}" ]]; then
# TODO: If there is a line about updating the same tool in the "Unreleased" section, replace it.
msg="Update \`${name}@latest\` to ${new_version}"
sed -Ei "s/^## \\[Unreleased\\]/## [Unreleased]\\n\\n- ${msg}./" CHANGELOG.md
git add "${manifest}" CHANGELOG.md
else
msg="Update ${name} manifest"
git add "${manifest}"
fi
git commit -m "${msg}"
has_update=1
fi
done
if [[ -n "${has_update}" ]] && [[ -n "${GITHUB_OUTPUT:-}" ]]; then
printf 'success=false\n' >>"${GITHUB_OUTPUT}"
printf 'success=false\n' >>"${GITHUB_OUTPUT}"
fi

View File

@@ -8,181 +8,181 @@ cd -- "$(dirname -- "$0")"/../..
# They don't provide prebuilt binaries for musl or old glibc host.
# version `GLIBC_2.34' not found
glibc_pre_2_34_incompat=(
cargo-cyclonedx
cargo-spellcheck
wait-for-them
xbuild
cargo-cyclonedx
cargo-spellcheck
wait-for-them
xbuild
)
# version `GLIBC_2.31' not found
glibc_pre_2_31_incompat=(
"${glibc_pre_2_34_incompat[@]}"
cargo-sort
espup
zola
"${glibc_pre_2_34_incompat[@]}"
cargo-sort
espup
zola
)
# version `GLIBC_2.28' not found
glibc_pre_2_28_incompat=(
"${glibc_pre_2_31_incompat[@]}"
wasmtime
"${glibc_pre_2_31_incompat[@]}"
wasmtime
)
# version `GLIBC_2.27' not found
glibc_pre_2_27_incompat=(
"${glibc_pre_2_28_incompat[@]}"
cargo-watch
mdbook-linkcheck
protoc
valgrind
"${glibc_pre_2_28_incompat[@]}"
cargo-watch
mdbook-linkcheck
protoc
valgrind
)
# version `GLIBC_2.17' not found
glibc_pre_2_17_incompat=(
"${glibc_pre_2_27_incompat[@]}"
deepsource
"${glibc_pre_2_27_incompat[@]}"
deepsource
)
musl_incompat=(
"${glibc_pre_2_17_incompat[@]}"
"${glibc_pre_2_17_incompat[@]}"
)
win2019_gnu_incompat=(
cargo-spellcheck
cargo-spellcheck
)
incompat_tools=()
case "${1:-}" in
'') version=latest ;;
major.minor.patch | major.minor | major)
version="$1"
# Specifying the version of valgrind and cargo-binstall is not supported.
incompat_tools+=(valgrind cargo-binstall)
;;
*)
printf 'tool=%s\n', "$1"
exit 1
;;
'') version=latest ;;
major.minor.patch | major.minor | major)
version="$1"
# Specifying the version of valgrind and cargo-binstall is not supported.
incompat_tools+=(valgrind cargo-binstall)
;;
*)
printf 'tool=%s\n', "$1"
exit 1
;;
esac
runner="${2:-}"
bash="${3:-}"
case "$(uname -s)" in
Linux)
host_os=linux
ldd_version=$(ldd --version 2>&1 || true)
if grep -Fq musl <<<"${ldd_version}"; then
incompat_tools+=("${musl_incompat[@]}")
else
host_glibc_version=$(grep -E "GLIBC|GNU libc" <<<"${ldd_version}" | sed "s/.* //g")
higher_glibc_version=$(sort -Vu <<<"2.34"$'\n'"${host_glibc_version}" | tail -1)
Linux)
host_os=linux
ldd_version=$(ldd --version 2>&1 || true)
if grep -Fq musl <<<"${ldd_version}"; then
incompat_tools+=("${musl_incompat[@]}")
else
host_glibc_version=$(grep -E "GLIBC|GNU libc" <<<"${ldd_version}" | sed "s/.* //g")
higher_glibc_version=$(sort -Vu <<<"2.34"$'\n'"${host_glibc_version}" | tail -1)
if [[ "${higher_glibc_version}" != "${host_glibc_version}" ]]; then
higher_glibc_version=$(sort -Vu <<<"2.31"$'\n'"${host_glibc_version}" | tail -1)
if [[ "${higher_glibc_version}" != "${host_glibc_version}" ]]; then
higher_glibc_version=$(sort -Vu <<<"2.28"$'\n'"${host_glibc_version}" | tail -1)
if [[ "${higher_glibc_version}" != "${host_glibc_version}" ]]; then
higher_glibc_version=$(sort -Vu <<<"2.27"$'\n'"${host_glibc_version}" | tail -1)
if [[ "${higher_glibc_version}" != "${host_glibc_version}" ]]; then
higher_glibc_version=$(sort -Vu <<<"2.31"$'\n'"${host_glibc_version}" | tail -1)
if [[ "${higher_glibc_version}" != "${host_glibc_version}" ]]; then
higher_glibc_version=$(sort -Vu <<<"2.28"$'\n'"${host_glibc_version}" | tail -1)
if [[ "${higher_glibc_version}" != "${host_glibc_version}" ]]; then
higher_glibc_version=$(sort -Vu <<<"2.27"$'\n'"${host_glibc_version}" | tail -1)
if [[ "${higher_glibc_version}" != "${host_glibc_version}" ]]; then
higher_glibc_version=$(sort -Vu <<<"2.17"$'\n'"${host_glibc_version}" | tail -1)
if [[ "${higher_glibc_version}" != "${host_glibc_version}" ]]; then
incompat_tools+=("${glibc_pre_2_17_incompat[@]}")
else
incompat_tools+=("${glibc_pre_2_27_incompat[@]}")
fi
else
incompat_tools+=("${glibc_pre_2_28_incompat[@]}")
fi
else
incompat_tools+=("${glibc_pre_2_31_incompat[@]}")
fi
else
incompat_tools+=("${glibc_pre_2_34_incompat[@]}")
fi
higher_glibc_version=$(sort -Vu <<<"2.17"$'\n'"${host_glibc_version}" | tail -1)
if [[ "${higher_glibc_version}" != "${host_glibc_version}" ]]; then
incompat_tools+=("${glibc_pre_2_17_incompat[@]}")
else
incompat_tools+=("${glibc_pre_2_27_incompat[@]}")
fi
else
incompat_tools+=("${glibc_pre_2_28_incompat[@]}")
fi
else
incompat_tools+=("${glibc_pre_2_31_incompat[@]}")
fi
else
incompat_tools+=("${glibc_pre_2_34_incompat[@]}")
fi
if ! type -P snap >/dev/null; then
incompat_tools+=(valgrind)
fi
fi
if ! type -P snap >/dev/null; then
incompat_tools+=(valgrind)
fi
;;
Darwin) host_os=macos ;;
MINGW* | MSYS* | CYGWIN* | Windows_NT)
host_os=windows
case "${bash}" in
msys64 | cygwin)
if [[ "${runner}" == "windows-2019" ]]; then
incompat_tools+=("${win2019_gnu_incompat[@]}")
fi
;;
Darwin) host_os=macos ;;
MINGW* | MSYS* | CYGWIN* | Windows_NT)
host_os=windows
case "${bash}" in
msys64 | cygwin)
if [[ "${runner}" == "windows-2019" ]]; then
incompat_tools+=("${win2019_gnu_incompat[@]}")
fi
;;
esac
;;
*) bail "unrecognized OS type '$(uname -s)'" ;;
esac
;;
*) bail "unrecognized OS type '$(uname -s)'" ;;
esac
# See main.sh
case "$(uname -m)" in
aarch64 | arm64) host_arch=aarch64 ;;
xscale | arm | armv*l) bail "32-bit Arm runner is not supported yet by this action; if you need support for this platform, please submit an issue at <https://github.com/taiki-e/install-action>" ;;
*) host_arch=x86_64 ;;
aarch64 | arm64) host_arch=aarch64 ;;
xscale | arm | armv*l) bail "32-bit Arm runner is not supported yet by this action; if you need support for this platform, please submit an issue at <https://github.com/taiki-e/install-action>" ;;
*) host_arch=x86_64 ;;
esac
tools=()
for manifest in tools/codegen/base/*.json; do
tool_name="${manifest##*/}"
tool_name="${tool_name%.*}"
# cross -V requires rustc
if [[ "${tool_name}" == "cross" ]] && ! type -P rustc >/dev/null; then
tool_name="${manifest##*/}"
tool_name="${tool_name%.*}"
# cross -V requires rustc
if [[ "${tool_name}" == "cross" ]] && ! type -P rustc >/dev/null; then
continue
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
continue
fi
;;
*)
if [[ "$(jq -r ".platform.x86_64_${host_os}" "${manifest}")" == "null" ]] && [[ "$(jq -r ".platform.${host_arch}_${host_os}" "${manifest}")" == "null" ]]; then
continue
fi
;;
esac
for incompat in ${incompat_tools[@]+"${incompat_tools[@]}"}; do
if [[ "${incompat}" == "${tool_name}" ]]; then
tool_name=''
break
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
continue
fi
;;
*)
if [[ "$(jq -r ".platform.x86_64_${host_os}" "${manifest}")" == "null" ]] && [[ "$(jq -r ".platform.${host_arch}_${host_os}" "${manifest}")" == "null" ]]; then
continue
fi
;;
esac
for incompat in ${incompat_tools[@]+"${incompat_tools[@]}"}; do
if [[ "${incompat}" == "${tool_name}" ]]; then
tool_name=''
break
fi
done
if [[ -n "${tool_name}" ]]; then
if [[ "${version}" != "latest" ]]; then
latest_version=$(jq -r '.latest.version' "manifests/${tool_name}.json")
case "${version}" in
major.minor.patch) tool_name+="@${latest_version}" ;;
major.minor) tool_name+="@${latest_version%.*}" ;;
major) tool_name+="@${latest_version%%.*}" ;;
*) exit 1 ;;
esac
fi
if [[ "${tool_name}" != *"@0" ]] && [[ "${tool_name}" != *"@0.0" ]]; then
tools+=("${tool_name}")
fi
done
if [[ -n "${tool_name}" ]]; then
if [[ "${version}" != "latest" ]]; then
latest_version=$(jq -r '.latest.version' "manifests/${tool_name}.json")
case "${version}" in
major.minor.patch) tool_name+="@${latest_version}" ;;
major.minor) tool_name+="@${latest_version%.*}" ;;
major) tool_name+="@${latest_version%%.*}" ;;
*) exit 1 ;;
esac
fi
if [[ "${tool_name}" != *"@0" ]] && [[ "${tool_name}" != *"@0.0" ]]; then
tools+=("${tool_name}")
fi
fi
done
if [[ "${version}" != "latest" ]]; then
tools_tmp=()
for tool in "${tools[@]}"; do
tools_tmp+=("${tool}")
done
tools=("${tools_tmp[@]}")
tools_tmp=()
for tool in "${tools[@]}"; do
tools_tmp+=("${tool}")
done
tools=("${tools_tmp[@]}")
fi
# Not manifest-based
case "${host_os}" in
linux*)
# Installing snap to container is difficult...
# Specifying the version of valgrind is not supported.
if type -P snap >/dev/null && [[ "${version}" == "latest" ]]; then
tools+=(valgrind)
fi
;;
linux*)
# Installing snap to container is difficult...
# Specifying the version of valgrind is not supported.
if type -P snap >/dev/null && [[ "${version}" == "latest" ]]; then
tools+=(valgrind)
fi
;;
esac
# cargo-watch/watchexec-cli is supported by cargo-binstall (through quickinstall)
case "${version}" in
latest) tools+=(cargo-watch watchexec-cli) ;;
major.minor.patch) tools+=(cargo-watch@8.5.2 watchexec-cli@2.1.2) ;;
major.minor) tools+=(cargo-watch@8.5 watchexec-cli@2.1) ;;
major) tools+=(cargo-watch@8 watchexec-cli@2) ;;
*) exit 1 ;;
latest) tools+=(cargo-watch watchexec-cli) ;;
major.minor.patch) tools+=(cargo-watch@8.5.2 watchexec-cli@2.1.2) ;;
major.minor) tools+=(cargo-watch@8.5 watchexec-cli@2.1) ;;
major) tools+=(cargo-watch@8 watchexec-cli@2) ;;
*) exit 1 ;;
esac
# sort and dedup