Reduce uname usage

This commit is contained in:
Taiki Endo
2026-05-05 05:37:18 +09:00
parent ca67a3acf1
commit fbb8be9fc5
3 changed files with 42 additions and 23 deletions

View File

@@ -27,6 +27,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
# tool: rust@nightly + rustfmt + wasm32-wasip1 # tool: rust@nightly + rustfmt + wasm32-wasip1
``` ```
- Fix issue where x86_64 binary will be installed on AArch64 Windows even when AArch64 Windows binary available.
## [2.76.0] - 2026-05-04 ## [2.76.0] - 2026-05-04
- Support `mdbook-d2`. ([#1737](https://github.com/taiki-e/install-action/pull/1737), thanks @nhu) - Support `mdbook-d2`. ([#1737](https://github.com/taiki-e/install-action/pull/1737), thanks @nhu)

View File

@@ -54,6 +54,8 @@ runs:
INPUT_FALLBACK: ${{ inputs.fallback }} INPUT_FALLBACK: ${{ inputs.fallback }}
DEFAULT_GITHUB_TOKEN: ${{ inputs.fallback == 'cargo-binstall' && github.token || '' }} DEFAULT_GITHUB_TOKEN: ${{ inputs.fallback == 'cargo-binstall' && github.token || '' }}
ACTION_USER_AGENT: ${{ github.action_repository }} (${{ github.action_ref }}) ACTION_USER_AGENT: ${{ github.action_repository }} (${{ github.action_ref }})
RUNNER_OS: ${{ runner.os }}
RUNNER_ARCH: ${{ runner.arch }}
if: runner.os != 'Windows' if: runner.os != 'Windows'
# Use pwsh and retry on bash startup failure to work around windows-11-arm runner bug: # Use pwsh and retry on bash startup failure to work around windows-11-arm runner bug:
# https://github.com/actions/partner-runner-images/issues/169 # https://github.com/actions/partner-runner-images/issues/169
@@ -88,4 +90,6 @@ runs:
INPUT_FALLBACK: ${{ inputs.fallback }} INPUT_FALLBACK: ${{ inputs.fallback }}
DEFAULT_GITHUB_TOKEN: ${{ inputs.fallback == 'cargo-binstall' && github.token || '' }} DEFAULT_GITHUB_TOKEN: ${{ inputs.fallback == 'cargo-binstall' && github.token || '' }}
ACTION_USER_AGENT: ${{ github.action_repository }} (${{ github.action_ref }}) ACTION_USER_AGENT: ${{ github.action_repository }} (${{ github.action_ref }})
RUNNER_OS: ${{ runner.os }}
RUNNER_ARCH: ${{ runner.arch }}
if: runner.os == 'Windows' if: runner.os == 'Windows'

31
main.sh
View File

@@ -515,10 +515,13 @@ token="${GITHUB_TOKEN:-"${GH_TOKEN:-"${DEFAULT_GITHUB_TOKEN:-}"}"}"
# via `ps -Eww` on macOS. It only reduces the risk of leaks. # via `ps -Eww` on macOS. It only reduces the risk of leaks.
unset GITHUB_TOKEN GH_TOKEN DEFAULT_GITHUB_TOKEN unset GITHUB_TOKEN GH_TOKEN DEFAULT_GITHUB_TOKEN
# Refs: https://github.com/rust-lang/rustup/blob/HEAD/rustup-init.sh # Refs:
# - https://github.com/rust-lang/rustup/blob/HEAD/rustup-init.sh
# - https://docs.github.com/en/actions/reference/workflows-and-actions/contexts#runner-context
# NB: Sync with tools/ci/tool-list.sh.
base_distro='' base_distro=''
exe='' exe=''
case "$(uname -s)" in case "${RUNNER_OS}" in
Linux) Linux)
host_os=linux host_os=linux
ldd_version=$(ldd --version 2>&1 || true) ldd_version=$(ldd --version 2>&1 || true)
@@ -568,16 +571,15 @@ case "$(uname -s)" in
;; ;;
esac esac
;; ;;
Darwin) host_os=macos ;; macOS) host_os=macos ;;
MINGW* | MSYS* | CYGWIN* | Windows_NT) Windows)
host_os=windows host_os=windows
exe=.exe exe=.exe
;; ;;
*) bail "unrecognized OS type '$(uname -s)'" ;; *) bail "unrecognized runner.os '${RUNNER_OS}'" ;;
esac esac
# NB: Sync with tools/ci/tool-list.sh. case "${RUNNER_ARCH}" in
case "$(uname -m)" in X64) host_arch=x86_64 ;;
aarch64 | arm64) host_arch=aarch64 ;;
# Ignore 32-bit Arm for now, as we need to consider the version and whether hard-float is supported. # Ignore 32-bit Arm for now, as we need to consider the version and whether hard-float is supported.
# https://github.com/rust-lang/rustup/pull/593 # https://github.com/rust-lang/rustup/pull/593
# https://github.com/cross-rs/cross/pull/1018 # https://github.com/cross-rs/cross/pull/1018
@@ -586,6 +588,16 @@ case "$(uname -m)" in
# Does it seem only armv7l+ is supported? # Does it seem only armv7l+ is supported?
# https://github.com/actions/runner/blob/v2.321.0/src/Misc/externals.sh#L178 # https://github.com/actions/runner/blob/v2.321.0/src/Misc/externals.sh#L178
# https://github.com/actions/runner/issues/688 # https://github.com/actions/runner/issues/688
ARM) bail "32-bit Arm runner is currently not supported by this action; if you need support for this platform, please submit an issue at <https://github.com/taiki-e/install-action>" ;;
X86) bail "32-bit x86 runner is currently not supported by this action; if you need support for this platform, please submit an issue at <https://github.com/taiki-e/install-action>" ;;
ARM64) host_arch=aarch64 ;;
PPC64LE) host_arch=powerpc64le ;;
RISCV64) host_arch=riscv64 ;;
S390X) host_arch=s390x ;;
*)
info "unrecognized runner.arch '${RUNNER_ARCH}'; fallback to uname -m"
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>" ;; 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>" ;;
ppc64le) host_arch=powerpc64le ;; ppc64le) host_arch=powerpc64le ;;
riscv64) host_arch=riscv64 ;; riscv64) host_arch=riscv64 ;;
@@ -599,9 +611,10 @@ case "$(uname -m)" in
# And IBM provides runners for powerpc64le/s390x Linux. # And IBM provides runners for powerpc64le/s390x Linux.
# https://github.com/IBM/actionspz # https://github.com/IBM/actionspz
# So we can assume x86_64 unless it has a known non-x86_64 uname -m result. # So we can assume x86_64 unless it has a known non-x86_64 uname -m result.
# TODO: uname -m on windows-11-arm returns "x86_64"
*) host_arch=x86_64 ;; *) host_arch=x86_64 ;;
esac esac
;;
esac
info "host platform: ${host_arch}_${host_os}" info "host platform: ${host_arch}_${host_os}"
home="${HOME:-}" home="${HOME:-}"