mirror of
https://github.com/taiki-e/install-action.git
synced 2025-12-27 01:54:13 -05:00
Add fallback: cargo-install input option to use cargo install for fallback
This commit is contained in:
31
.github/workflows/ci.yml
vendored
31
.github/workflows/ci.yml
vendored
@@ -162,6 +162,37 @@ jobs:
|
||||
run: cargo-nextest nextest --version && taplo --version
|
||||
shell: sh
|
||||
|
||||
test-fallback:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
fallback:
|
||||
- none
|
||||
- cargo-install
|
||||
runs-on: ubuntu-24.04-arm
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- uses: taiki-e/checkout-action@v1
|
||||
# cross attempts to install rust-src when Cargo.toml is available even if `cross --version`
|
||||
- run: rm -- Cargo.toml
|
||||
- run: env
|
||||
- uses: ./
|
||||
id: install
|
||||
continue-on-error: ${{ matrix.fallback == 'none' }}
|
||||
with:
|
||||
tool: parse-changelog@0.4.6
|
||||
fallback: ${{ matrix.fallback }}
|
||||
- run: exit 1
|
||||
if: matrix.fallback == 'none' && steps.install.outcome != 'failure'
|
||||
- name: Test bash
|
||||
run: parse-changelog --version
|
||||
shell: bash
|
||||
if: matrix.fallback != 'none'
|
||||
- name: Test sh
|
||||
run: parse-changelog --version
|
||||
shell: sh
|
||||
if: matrix.fallback != 'none'
|
||||
|
||||
test-container:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
@@ -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: cargo-install` input option to use `cargo install` instead of `cargo-binstall` for fallback.
|
||||
|
||||
- Accept `typos-cli` as an alias for `typos`.
|
||||
|
||||
- Accept `wasm-bindgen-cli` as an alias for `wasm-bindgen`.
|
||||
|
||||
@@ -86,8 +86,9 @@ If you want to ensure that fallback is not used, use `fallback: none`.
|
||||
with:
|
||||
tool: cargo-hack
|
||||
# Possible values:
|
||||
# - none: disable all fallback
|
||||
# - cargo-binstall (default): cargo-binstall (includes quickinstall)
|
||||
# - none: disable all fallback options
|
||||
# - cargo-binstall (default): use cargo-binstall (includes quickinstall)
|
||||
# - cargo-install: use `cargo install`
|
||||
fallback: none
|
||||
```
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ inputs:
|
||||
required: false
|
||||
default: 'true'
|
||||
fallback:
|
||||
description: Whether to use fallback (none or cargo-binstall)
|
||||
description: Whether to use fallback (none, cargo-binstall, cargo-install)
|
||||
required: false
|
||||
default: 'cargo-binstall'
|
||||
|
||||
|
||||
46
main.sh
46
main.sh
@@ -459,8 +459,8 @@ esac
|
||||
|
||||
fallback="${INPUT_FALLBACK:-}"
|
||||
case "${fallback}" in
|
||||
none | cargo-binstall) ;;
|
||||
*) bail "'fallback' input option must be 'none' or 'cargo-binstall': '${fallback}'" ;;
|
||||
none | cargo-binstall | cargo-install) ;;
|
||||
*) bail "'fallback' input option must be 'none', 'cargo-binstall', or 'cargo-install': '${fallback}'" ;;
|
||||
esac
|
||||
|
||||
# Refs: https://github.com/rust-lang/rustup/blob/HEAD/rustup-init.sh
|
||||
@@ -859,20 +859,30 @@ if [[ ${#unsupported_tools[@]} -gt 0 ]]; then
|
||||
case "${fallback}" in
|
||||
none) bail "install-action does not support ${unsupported_tools[*]} (fallback is disabled by 'fallback: none' input option)" ;;
|
||||
esac
|
||||
info "install-action does not support ${unsupported_tools[*]}; fallback to cargo-binstall"
|
||||
IFS=$'\n\t'
|
||||
install_cargo_binstall
|
||||
if [[ -z "${GITHUB_TOKEN:-}" ]] && [[ -n "${DEFAULT_GITHUB_TOKEN:-}" ]]; then
|
||||
export GITHUB_TOKEN="${DEFAULT_GITHUB_TOKEN}"
|
||||
fi
|
||||
# By default, cargo-binstall enforce downloads over secure transports only.
|
||||
# As a result, http will be disabled, and it will also set
|
||||
# min tls version to be 1.2
|
||||
cargo-binstall binstall --force --no-confirm --locked "${unsupported_tools[@]}"
|
||||
if ! type -P cargo >/dev/null; then
|
||||
_bin_dir=$(canonicalize_windows_path "${home}/.cargo/bin")
|
||||
# TODO: avoid this when already added
|
||||
info "adding '${_bin_dir}' to PATH"
|
||||
printf '%s\n' "${_bin_dir}" >>"${GITHUB_PATH}"
|
||||
fi
|
||||
case "${fallback}" in
|
||||
cargo-binstall)
|
||||
info "install-action does not support ${unsupported_tools[*]}; fallback to cargo-binstall"
|
||||
IFS=$'\n\t'
|
||||
install_cargo_binstall
|
||||
if [[ -z "${GITHUB_TOKEN:-}" ]] && [[ -n "${DEFAULT_GITHUB_TOKEN:-}" ]]; then
|
||||
export GITHUB_TOKEN="${DEFAULT_GITHUB_TOKEN}"
|
||||
fi
|
||||
# By default, cargo-binstall enforce downloads over secure transports only.
|
||||
# As a result, http will be disabled, and it will also set
|
||||
# min tls version to be 1.2
|
||||
cargo-binstall binstall --force --no-confirm --locked "${unsupported_tools[@]}"
|
||||
if ! type -P cargo >/dev/null; then
|
||||
_bin_dir=$(canonicalize_windows_path "${home}/.cargo/bin")
|
||||
# TODO: avoid this when already added
|
||||
info "adding '${_bin_dir}' to PATH"
|
||||
printf '%s\n' "${_bin_dir}" >>"${GITHUB_PATH}"
|
||||
fi
|
||||
;;
|
||||
cargo-install)
|
||||
info "install-action does not support ${unsupported_tools[*]}; fallback to cargo-install"
|
||||
IFS=$'\n\t'
|
||||
cargo install --locked "${unsupported_tools[@]}"
|
||||
;;
|
||||
*) bail "unhandled fallback ${fallback}" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user