-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
action.yml
71 lines (68 loc) · 2.22 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: cache-cargo-install-action
description: GitHub Action for cargo install with cache
inputs:
tool:
description: Crate to install
required: true
locked:
description: Use --locked flag
required: false
default: 'true'
git:
description: >
Install from the specified Git URL
This currently requires one of 'tag' or 'rev' input option.
required: false
tag:
description: Tag to use when installing from git
required: false
rev:
description: Specific commit to use when installing from git
required: false
# Note:
# - inputs.* should be manually mapped to INPUT_* due to https://github.com/actions/runner/issues/665
# - Use GITHUB_*/RUNNER_* instead of github.*/runner.* due to https://github.com/actions/runner/issues/2185
runs:
using: composite
steps:
- name: Pre Cache
id: pre
run: bash --noprofile --norc "${GITHUB_ACTION_PATH:?}/pre.sh"
shell: bash
env:
INPUT_TOOL: ${{ inputs.tool }}
INPUT_LOCKED: ${{ inputs.locked }}
INPUT_GIT: ${{ inputs.git }}
INPUT_TAG: ${{ inputs.tag }}
INPUT_REV: ${{ inputs.rev }}
- name: Restore Cache
id: cache
uses: actions/cache@v4
with:
path: ${{ steps.pre.outputs.path }}
key: ${{ steps.pre.outputs.key }}
- name: Install ${{ inputs.tool }}
run: |
export CARGO_NET_RETRY=10
# shellcheck disable=SC2206
args=(-f "${{ steps.pre.outputs.tool }}" --root "${RUNNER_TOOL_CACHE}/${{ steps.pre.outputs.tool }}" ${{ steps.pre.outputs.locked }})
if [[ -n "${{ steps.pre.outputs.git }}" ]]; then
if [[ -n "${{ steps.pre.outputs.tag }}" ]]; then
(
set -x
cargo install "${args[@]}" --git "${{ steps.pre.outputs.git }}" --tag "${{ steps.pre.outputs.tag }}"
)
else
(
set -x
cargo install "${args[@]}" --git "${{ steps.pre.outputs.git }}" --rev "${{ steps.pre.outputs.rev }}"
)
fi
else
(
set -x
cargo install "${args[@]}" --version "${{ steps.pre.outputs.version }}"
)
fi
shell: bash
if: steps.cache.outputs.cache-hit != 'true'