mirror of
https://github.com/taiki-e/install-action.git
synced 2026-05-11 07:00:25 +00:00
Fix install failures in edge cases
This commit is contained in:
1
.github/.cspell/project-dictionary.txt
vendored
1
.github/.cspell/project-dictionary.txt
vendored
@@ -18,6 +18,7 @@ nextest
|
|||||||
protobuf
|
protobuf
|
||||||
protoc
|
protoc
|
||||||
protocolbuffers
|
protocolbuffers
|
||||||
|
pwsh
|
||||||
quickinstall
|
quickinstall
|
||||||
rockylinux
|
rockylinux
|
||||||
rustwasm
|
rustwasm
|
||||||
|
|||||||
15
.github/workflows/ci.yml
vendored
15
.github/workflows/ci.yml
vendored
@@ -64,6 +64,21 @@ jobs:
|
|||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
tool: ${{ matrix.tool }}
|
tool: ${{ matrix.tool }}
|
||||||
|
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
|
||||||
|
- name: Test bash
|
||||||
|
run: just --version; shfmt --version; protoc --version
|
||||||
|
shell: bash
|
||||||
|
- name: Test sh
|
||||||
|
run: just --version; shfmt --version; protoc --version
|
||||||
|
shell: sh
|
||||||
|
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'macos')
|
||||||
|
- name: Test pwsh
|
||||||
|
run: just --version; shfmt --version; protoc --version
|
||||||
|
shell: pwsh
|
||||||
|
- name: Test powershell
|
||||||
|
run: just --version; shfmt --version; protoc --version
|
||||||
|
shell: powershell
|
||||||
|
if: startsWith(matrix.os, 'windows')
|
||||||
# We use the version output to check the version of binstall, but they
|
# We use the version output to check the version of binstall, but they
|
||||||
# several times change the version output format in the past so we need to
|
# several times change the version output format in the past so we need to
|
||||||
# check it with CI. (e.g., 0.14.0->0.16.0 update change it
|
# check it with CI. (e.g., 0.14.0->0.16.0 update change it
|
||||||
|
|||||||
@@ -10,6 +10,14 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
- Support `cargo-tarpaulin`. ([#65](https://github.com/taiki-e/install-action/pull/65), thanks @orhun)
|
||||||
|
|
||||||
|
- Allow installing cargo subcommands without `cargo`.
|
||||||
|
|
||||||
|
- Fix issue where installed non-Rust related binaries cannot be found from PowerShell on Windows. Rust-related binaries, Unix shells such as bash, and non-Windows OS are not affected by this issue.
|
||||||
|
|
||||||
|
- 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.
|
||||||
|
|
||||||
## [2.3.5] - 2023-02-04
|
## [2.3.5] - 2023-02-04
|
||||||
|
|
||||||
- Update `cross@latest` to 0.2.5.
|
- Update `cross@latest` to 0.2.5.
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ This action has been tested for GitHub-hosted runners (Ubuntu, macOS, Windows) a
|
|||||||
To use this action in self-hosted runners or in containers, at least the following tools are required:
|
To use this action in self-hosted runners or in containers, at least the following tools are required:
|
||||||
|
|
||||||
- bash
|
- bash
|
||||||
- cargo (if you install cargo subcommands or use cargo-binstall fallback)
|
- cargo (if you use cargo-binstall fallback)
|
||||||
|
|
||||||
## Related Projects
|
## Related Projects
|
||||||
|
|
||||||
|
|||||||
33
main.sh
33
main.sh
@@ -62,7 +62,7 @@ download_and_extract() {
|
|||||||
bin_dir="${HOME}/.install-action/bin"
|
bin_dir="${HOME}/.install-action/bin"
|
||||||
if [[ ! -d "${bin_dir}" ]]; then
|
if [[ ! -d "${bin_dir}" ]]; then
|
||||||
mkdir -p "${bin_dir}"
|
mkdir -p "${bin_dir}"
|
||||||
echo "${bin_dir}" >>"${GITHUB_PATH}"
|
canonicalize_windows_path "${bin_dir}" >>"${GITHUB_PATH}"
|
||||||
export PATH="${PATH}:${bin_dir}"
|
export PATH="${PATH}:${bin_dir}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -294,6 +294,12 @@ sys_install() {
|
|||||||
fedora) dnf_install "$@" ;;
|
fedora) dnf_install "$@" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
canonicalize_windows_path() {
|
||||||
|
case "${host_os}" in
|
||||||
|
windows) sed <<<"$1" 's/^\/c\//C:\\/' ;;
|
||||||
|
*) echo "$1" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
# cargo-binstall may call `cargo install` on their fallback: https://github.com/taiki-e/install-action/pull/54#issuecomment-1383140833
|
# cargo-binstall may call `cargo install` on their fallback: https://github.com/taiki-e/install-action/pull/54#issuecomment-1383140833
|
||||||
# cross calls rustup on `cross --version` if the current directly is cargo workspace.
|
# cross calls rustup on `cross --version` if the current directly is cargo workspace.
|
||||||
@@ -395,7 +401,10 @@ esac
|
|||||||
|
|
||||||
tmp_dir="${HOME}/.install-action/tmp"
|
tmp_dir="${HOME}/.install-action/tmp"
|
||||||
cargo_bin="${CARGO_HOME:-"${HOME}/.cargo"}/bin"
|
cargo_bin="${CARGO_HOME:-"${HOME}/.cargo"}/bin"
|
||||||
if [[ ! -d "${cargo_bin}" ]]; then
|
# If $CARGO_HOME does not exist, or cargo installed outside of $CARGO_HOME/bin
|
||||||
|
# is used ($CARGO_HOME/bin is most likely not included in the PATH), fallback to
|
||||||
|
# /usr/local/bin or $HOME/.install-action/bin.
|
||||||
|
if [[ ! -d "${cargo_bin}" ]] || [[ "${host_os}" != "windows" ]] && [[ "$(type -P cargo || true)" != "${cargo_bin}/cargo${exe}" ]]; then
|
||||||
cargo_bin=/usr/local/bin
|
cargo_bin=/usr/local/bin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -438,7 +447,7 @@ for tool in "${tools[@]}"; do
|
|||||||
if [[ ! -d "${bin_dir}" ]]; then
|
if [[ ! -d "${bin_dir}" ]]; then
|
||||||
mkdir -p "${bin_dir}"
|
mkdir -p "${bin_dir}"
|
||||||
mkdir -p "${include_dir}"
|
mkdir -p "${include_dir}"
|
||||||
echo "${bin_dir}" >>"${GITHUB_PATH}"
|
canonicalize_windows_path "${bin_dir}" >>"${GITHUB_PATH}"
|
||||||
export PATH="${PATH}:${bin_dir}"
|
export PATH="${PATH}:${bin_dir}"
|
||||||
fi
|
fi
|
||||||
if ! type -P unzip &>/dev/null; then
|
if ! type -P unzip &>/dev/null; then
|
||||||
@@ -454,9 +463,7 @@ for tool in "${tools[@]}"; do
|
|||||||
mv "bin/protoc${exe}" "${bin_dir}/"
|
mv "bin/protoc${exe}" "${bin_dir}/"
|
||||||
mkdir -p "${include_dir}/"
|
mkdir -p "${include_dir}/"
|
||||||
cp -r include/. "${include_dir}/"
|
cp -r include/. "${include_dir}/"
|
||||||
case "${host_os}" in
|
bin_dir=$(canonicalize_windows_path "${bin_dir}")
|
||||||
windows) bin_dir=$(sed <<<"${bin_dir}" 's/^\/c\//C:\\/') ;;
|
|
||||||
esac
|
|
||||||
if [[ -z "${PROTOC:-}" ]]; then
|
if [[ -z "${PROTOC:-}" ]]; then
|
||||||
info "setting PROTOC environment variable"
|
info "setting PROTOC environment variable"
|
||||||
echo "PROTOC=${bin_dir}/protoc${exe}" >>"${GITHUB_ENV}"
|
echo "PROTOC=${bin_dir}/protoc${exe}" >>"${GITHUB_ENV}"
|
||||||
@@ -526,10 +533,22 @@ for tool in "${tools[@]}"; do
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
info "${tool} installed at $(type -P "${tool}${exe}")"
|
info "${tool} installed at $(type -P "${tool}${exe}")"
|
||||||
|
case "${tool}" in
|
||||||
|
cargo-*)
|
||||||
|
if type -P cargo &>/dev/null; then
|
||||||
case "${tool}" in
|
case "${tool}" in
|
||||||
cargo-udeps) x cargo udeps --help | head -1 ;; # cargo-udeps v0.1.30 does not support --version option
|
cargo-udeps) x cargo udeps --help | head -1 ;; # cargo-udeps v0.1.30 does not support --version option
|
||||||
cargo-valgrind) x cargo valgrind --help ;; # cargo-valgrind v2.1.0 does not support --version option
|
cargo-valgrind) x cargo valgrind --help ;; # cargo-valgrind v2.1.0 does not support --version option
|
||||||
cargo-*) x cargo "${tool#cargo-}" --version ;;
|
*) x cargo "${tool#cargo-}" --version ;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
case "${tool}" in
|
||||||
|
cargo-udeps) x "${tool}" udeps --help | head -1 ;; # cargo-udeps v0.1.30 does not support --version option
|
||||||
|
cargo-valgrind) x "${tool}" valgrind --help ;; # cargo-valgrind v2.1.0 does not support --version option
|
||||||
|
*) x "${tool}" "${tool#cargo-}" --version ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
;;
|
||||||
*) x "${tool}" --version ;;
|
*) x "${tool}" --version ;;
|
||||||
esac
|
esac
|
||||||
echo
|
echo
|
||||||
|
|||||||
Reference in New Issue
Block a user