diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c5d7890..30574070 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com - Fix issue where x86_64 binary will be installed on AArch64 Windows even when AArch64 Windows binary available. +- Diagnostic improvements. + ## [2.76.0] - 2026-05-04 - Support `mdbook-d2`. ([#1737](https://github.com/taiki-e/install-action/pull/1737), thanks @nhu) diff --git a/action.yml b/action.yml index b4491fa7..56e9ce34 100644 --- a/action.yml +++ b/action.yml @@ -22,11 +22,14 @@ runs: using: composite steps: - run: | + bail() { + printf '::error::install-action: %s\n' "$*" + exit 1 + } # If /bin/sh is dash, environment variable containing % is not imported, but is fine # because it also means that it will not be exposed to subprocess. if /usr/bin/env | grep -Eq '^BASH_FUNC_'; then - printf '::error::bash function injection via BASH_FUNC_ environment variable is not allowed for security reasons\n' - exit 1 + bail 'bash function injection via BASH_FUNC_ environment variable is not allowed for security reasons' fi if ! command -v bash >/dev/null; then if grep -Eq '^ID=alpine' /etc/os-release; then @@ -41,8 +44,7 @@ runs: fi printf '::endgroup::\n' else - printf '::error::install-action requires bash\n' - exit 1 + bail 'this action requires bash' fi fi bash --noprofile --norc "${GITHUB_ACTION_PATH:?}/main.sh" @@ -77,10 +79,10 @@ runs: exit $code } if ($i -lt 10) { - Write-Output "::warning::installation failed due to bash startup failure (); retrying..." + Write-Output "::warning::install-action: installation failed due to bash startup failure (); retrying..." } } - Write-Output "::error::installation failed due to bash startup failure (); this maybe resolved by re-running job" + Write-Output "::error::install-action: installation failed due to bash startup failure (); this maybe resolved by re-running job" exit 1 shell: pwsh env: diff --git a/main.sh b/main.sh index e25f42b1..6cdaa4b5 100755 --- a/main.sh +++ b/main.sh @@ -28,11 +28,11 @@ retry() { "$@" } bail() { - printf '::error::%s\n' "$*" + printf '::error::install-action: %s\n' "$*" exit 1 } warn() { - printf '::warning::%s\n' "$*" + printf '::warning::install-action: %s\n' "$*" } info() { printf >&2 'info: %s\n' "$*" @@ -382,7 +382,7 @@ install_cargo_binstall() { info "cargo-binstall already installed at ${cargo_bin}/cargo-binstall${exe}" install_binstall='' else - info "cargo-binstall already installed at ${cargo_bin}/cargo-binstall${exe}, but is not compatible version with install-action, upgrading" + info "cargo-binstall already installed at ${cargo_bin}/cargo-binstall${exe}, but is not compatible version with this action, upgrading" rm -- "${cargo_bin}/cargo-binstall${exe}" fi fi @@ -588,8 +588,8 @@ case "${RUNNER_ARCH}" in # 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/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 " ;; - 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 " ;; + ARM) bail "32-bit Arm runner is currently not supported; if you need support for this platform, please submit an issue at " ;; + X86) bail "32-bit x86 runner is currently not supported; if you need support for this platform, please submit an issue at " ;; ARM64) host_arch=aarch64 ;; PPC64LE) host_arch=powerpc64le ;; RISCV64) host_arch=riscv64 ;; @@ -598,13 +598,13 @@ case "${RUNNER_ARCH}" in 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 " ;; + xscale | arm | armv*l) bail "32-bit Arm runner is currently not supported; if you need support for this platform, please submit an issue at " ;; ppc64le) host_arch=powerpc64le ;; riscv64) host_arch=riscv64 ;; s390x) host_arch=s390x ;; # Very few tools provide prebuilt binaries for these. # TODO: fallback to `cargo install`? (binstall fallback is not good idea here as cargo-binstall doesn't provide prebuilt binaries for these.) - loongarch64 | mips | mips64 | ppc | ppc64 | sun4v) bail "$(uname -m) runner is not supported yet by this action; if you need support for this platform, please submit an issue at " ;; + loongarch64 | mips | mips64 | ppc | ppc64 | sun4v) bail "$(uname -m) runner is not supported yet; please submit an issue at " ;; # GitHub Actions Runner supports x86_64/AArch64/Arm Linux and x86_64/AArch64 Windows/macOS. # https://github.com/actions/runner/blob/v2.332.0/.github/workflows/build.yml#L24 # https://docs.github.com/en/actions/reference/runners/self-hosted-runners#supported-processor-architectures @@ -703,18 +703,18 @@ case "${host_os}" in fi printf '::endgroup::\n' ;; - *) warn "install-action requires at least jq and curl on non-Debian/Fedora/SUSE/Arch/Alpine-based Linux" ;; + *) warn "this action requires at least jq and curl on non-Debian/Fedora/SUSE/Arch/Alpine-based Linux" ;; esac fi ;; macos) if ! type -P jq >/dev/null || ! type -P curl >/dev/null; then - warn "install-action requires at least jq and curl on macOS" + warn "this action requires at least jq and curl on macOS" fi ;; windows) if ! type -P curl >/dev/null; then - warn "install-action requires at least curl on Windows" + warn "this action requires at least curl on Windows" fi if [[ -f "${install_action_dir}/jq/bin/jq.exe" ]]; then jq() { "${install_action_dir}/jq/bin/jq.exe" -b "$@"; } @@ -759,7 +759,7 @@ for tool in "${tools[@]}"; do if [[ "${tool}" != 'rust' ]]; then if [[ ! "${version}" =~ ^([1-9][0-9]*(\.[0-9]+(\.[0-9]+)?)?|0\.[1-9][0-9]*(\.[0-9]+)?|^0\.0\.[0-9]+)(-[0-9A-Za-z\.-]+)?$|^latest$ ]]; then if [[ ! "${version}" =~ ^([1-9][0-9]*(\.[0-9]+(\.[0-9]+)?)?|0\.[1-9][0-9]*(\.[0-9]+)?|^0\.0\.[0-9]+)(-[0-9A-Za-z\.-]+)?(\+[0-9A-Za-z\.-]+)?$|^latest$ ]]; then - bail "install-action does not support semver operators: '${version}'" + bail "semver operators are not supported in 'tool' input option: '${version}'" fi bail "install-action v2 does not support semver build-metadata: '${version}'; if you need these supports again, please submit an issue at " fi @@ -932,11 +932,11 @@ for tool in "${tools[@]}"; do info "installing ${tool}@${version}" case "${version}" in latest) ;; - *) warn "specifying the version of ${tool} is not supported yet by this action" ;; + *) warn "specifying the version of ${tool} is not supported" ;; esac case "${host_os}" in linux) ;; - macos | windows) bail "${tool} for non-Linux is not supported yet by this action" ;; + macos | windows) bail "${tool} for non-Linux is not supported" ;; *) bail "unsupported host OS '${host_os}' for ${tool}" ;; esac # libc6-dbg is needed to run Valgrind @@ -949,7 +949,7 @@ for tool in "${tools[@]}"; do cargo-binstall) case "${version}" in latest) ;; - *) warn "specifying the version of ${tool} is not supported by this action" ;; + *) warn "specifying the version of ${tool} is not supported" ;; esac install_cargo_binstall printf '\n'