mirror of
https://github.com/taiki-e/install-action
synced 2026-11-23 21:34:20 +00:00
Add fallback: skip input option
This commit is contained in:
@@ -300,6 +300,7 @@ jobs:
|
||||
matrix:
|
||||
include:
|
||||
- fallback: none
|
||||
- fallback: skip
|
||||
- fallback: cargo-install
|
||||
- fallback: cargo-binstall
|
||||
- fallback: cargo-binstall
|
||||
@@ -334,6 +335,9 @@ jobs:
|
||||
fallback: ${{ matrix.fallback }}
|
||||
- run: exit 1
|
||||
if: matrix.fallback == 'none' && steps.install.outcome != 'failure'
|
||||
- run: |
|
||||
! type -P parse-changelog
|
||||
if: matrix.fallback == 'skip'
|
||||
- run: |
|
||||
[[ "$("${RUNNER_TEMP}/binstall/bin/cargo-binstall" binstall -V)" == '0.0.0' ]] || exit 1
|
||||
[[ "$(cargo-binstall binstall -V)" == "$(jq -r '.latest.version' manifests/cargo-binstall.json)" ]] || exit 1
|
||||
@@ -341,8 +345,8 @@ jobs:
|
||||
- name: Test bash
|
||||
run: parse-changelog --version
|
||||
shell: bash
|
||||
if: matrix.fallback != 'none'
|
||||
if: matrix.fallback == 'cargo-binstall' || matrix.fallback == 'cargo-install'
|
||||
- name: Test sh
|
||||
run: parse-changelog --version
|
||||
shell: sh
|
||||
if: matrix.fallback != 'none'
|
||||
if: matrix.fallback == 'cargo-binstall' || matrix.fallback == 'cargo-install'
|
||||
|
||||
@@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- Add `fallback: skip` input option. This is similar to `fallback: none` but skip unsupported tools instead of error. ([#2052](https://github.com/taiki-e/install-action/issues/2052))
|
||||
|
||||
- Update `vacuum@latest` to 0.36.2.
|
||||
|
||||
- Update `release-plz@latest` to 0.4.3.
|
||||
|
||||
@@ -24,7 +24,7 @@ GitHub Action for installing development tools (mainly from GitHub Releases).
|
||||
| ---- | :------: | ----------- | ---- | ------- |
|
||||
| tool | **✓** | Tools to install (whitespace or comma separated list) | String | |
|
||||
| checksum | | Whether to enable checksums (strongly discouraged to disable) | Boolean | `true` |
|
||||
| fallback | | Whether to use fallback (none, cargo-binstall, or cargo-install) | String | `cargo-binstall` |
|
||||
| fallback | | Whether to use fallback (none, skip, cargo-binstall, or cargo-install) | String | `cargo-binstall` |
|
||||
|
||||
### Example workflow
|
||||
|
||||
@@ -101,14 +101,15 @@ See [TOOLS.md](TOOLS.md) for the list of tools that are installed from manifests
|
||||
|
||||
If a tool not included in the list above is specified, this action uses [cargo-binstall] as a fallback.
|
||||
|
||||
If you want to ensure that fallback is not used, use `fallback: none`.
|
||||
If you want to ensure that fallback is not used, use `fallback: none` or `fallback: skip`.
|
||||
|
||||
```yaml
|
||||
- uses: taiki-e/install-action@v2
|
||||
with:
|
||||
tool: cargo-hack
|
||||
# Possible values:
|
||||
# - none: disable all fallback options
|
||||
# - none: disable all fallback options (error on unsupported tools)
|
||||
# - skip: disable all fallback options (skip unsupported tools instead of error)
|
||||
# - cargo-binstall (default): use cargo-binstall (includes "quickinstall" and "install from source")
|
||||
# - cargo-install: use `cargo install`
|
||||
fallback: none
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ inputs:
|
||||
required: false
|
||||
default: 'true'
|
||||
fallback:
|
||||
description: Whether to use fallback (none, cargo-binstall, or cargo-install)
|
||||
description: Whether to use fallback (none, skip, cargo-binstall, or cargo-install)
|
||||
required: false
|
||||
default: 'cargo-binstall'
|
||||
|
||||
|
||||
@@ -329,6 +329,13 @@ read_manifest() {
|
||||
*) bail "unsupported OS type '${host_os}' for ${tool}" ;;
|
||||
esac
|
||||
}
|
||||
skip_unavailable_tool() {
|
||||
if [[ "${fallback}" == "skip" ]] && [[ "${download_info}" == "null" ]]; then
|
||||
info "$1@$2 for '${host_arch}_${host_os}' is not supported (updating install-action might resolve this); skipping because of 'fallback: skip' input option"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
read_download_info() {
|
||||
local tool="$1"
|
||||
local version="$2"
|
||||
@@ -514,16 +521,17 @@ esac
|
||||
|
||||
fallback="${INPUT_FALLBACK:-}"
|
||||
case "${fallback}" in
|
||||
none | cargo-binstall | cargo-install) ;;
|
||||
*) bail "'fallback' input option must be 'none', 'cargo-binstall', or 'cargo-install': '${fallback}'" ;;
|
||||
none | skip | cargo-binstall | cargo-install) ;;
|
||||
*) bail "'fallback' input option must be 'none', 'skip', 'cargo-binstall', or 'cargo-install': '${fallback}'" ;;
|
||||
esac
|
||||
|
||||
# Unlike gh command, cargo-binstall reads GITHUB_TOKEN first via cli parser, and then reads GH_TOKEN.
|
||||
# https://github.com/cargo-bins/cargo-binstall/blob/v1.17.9/crates/bin/src/args.rs#L704
|
||||
token="${GITHUB_TOKEN:-"${GH_TOKEN:-"${DEFAULT_GITHUB_TOKEN:-}"}"}"
|
||||
# This prevents tokens from being exposed to subprocesses via environment variables.
|
||||
# Since the tokens remain in memory, setting `fallback: none` (which prevents the tokens from being
|
||||
# set in the first place) remains the best practice from a security standpoint, as readme says.
|
||||
# Since the tokens remain in memory, setting `fallback: none`, `fallback: skip`, or
|
||||
# `fallback: cargo-install` (which prevents the tokens from being set in the first place) remains
|
||||
# the best practice from a security standpoint, as readme says.
|
||||
# Note that this does not prevent token leaks via reading `/proc/*/environ` on Linux or
|
||||
# via `ps -Eww` on macOS. It only reduces the risk of leaks.
|
||||
unset GITHUB_TOKEN GH_TOKEN DEFAULT_GITHUB_TOKEN
|
||||
@@ -914,8 +922,11 @@ for tool in "${tools[@]}"; do
|
||||
installed_bin=("rustc${exe}" "cargo${exe}")
|
||||
;;
|
||||
protoc)
|
||||
info "installing ${tool}@${version}"
|
||||
read_manifest "protoc" "${version}"
|
||||
if skip_unavailable_tool "${tool}" "${version}"; then
|
||||
continue
|
||||
fi
|
||||
info "installing ${tool}@${version}"
|
||||
read_download_info "protoc" "${version}"
|
||||
# Copying files to /usr/local/include requires sudo, so do not use it.
|
||||
bin_dir="${install_action_dir}/bin"
|
||||
@@ -975,6 +986,12 @@ for tool in "${tools[@]}"; do
|
||||
latest) ;;
|
||||
*) warn "specifying the version of ${tool} is not supported" ;;
|
||||
esac
|
||||
if [[ "${fallback}" == "skip" ]]; then
|
||||
read_manifest "${tool}" "latest"
|
||||
if skip_unavailable_tool "${tool}" "latest"; then
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
install_cargo_binstall
|
||||
printf '\n'
|
||||
continue
|
||||
@@ -990,7 +1007,7 @@ for tool in "${tools[@]}"; do
|
||||
taplo-cli | typos-cli | wasm-bindgen-cli | wasmtime-cli) tool="${tool%-cli}" ;;
|
||||
esac
|
||||
|
||||
# Use cargo-binstall fallback if tool is not available.
|
||||
# Use fallback if tool is not available.
|
||||
if [[ ! -f "${manifest_dir}/${tool}.json" ]]; then
|
||||
case "${version}" in
|
||||
latest) unsupported_tools+=("${tool}") ;;
|
||||
@@ -999,8 +1016,11 @@ for tool in "${tools[@]}"; do
|
||||
continue
|
||||
fi
|
||||
|
||||
# Use cargo-binstall fallback if tool is available but the specified version not available.
|
||||
# Use fallback if tool is available but the specified version or platform is not available.
|
||||
read_manifest "${tool}" "${version}"
|
||||
if skip_unavailable_tool "${tool}" "${version}"; then
|
||||
continue
|
||||
fi
|
||||
if [[ "${download_info}" == "null" ]]; then
|
||||
if [[ "${rust_crate}" == "null" ]] || [[ "${fallback}" == "none" ]]; then
|
||||
bail "${tool} is supported but version ${version} for '${host_arch}_${host_os}' is not supported (updating install-action might resolve this)"
|
||||
@@ -1100,6 +1120,10 @@ if [[ ${#unsupported_tools[@]} -gt 0 ]]; then
|
||||
IFS=','
|
||||
case "${fallback}" in
|
||||
none) bail "install-action does not support ${unsupported_tools[*]} (updating install-action might resolve this); aborting because fallback is disabled by 'fallback: none' input option" ;;
|
||||
skip)
|
||||
info "install-action does not support ${unsupported_tools[*]} (updating install-action might resolve this); skipping because of 'fallback: skip' input option"
|
||||
exit 0
|
||||
;;
|
||||
cargo-binstall)
|
||||
case "${host_arch}" in
|
||||
x86_64 | aarch64 | riscv64) ;;
|
||||
|
||||
Reference in New Issue
Block a user