-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathaction.yml
More file actions
97 lines (94 loc) · 3.39 KB
/
action.yml
File metadata and controls
97 lines (94 loc) · 3.39 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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
features:
description: Comma-separated list of features to enable when installing the crate
required: false
default: ''
no-default-features:
description: Pass `--no-default-features` to `cargo install`
required: false
default: 'false'
all-features:
description: Pass `--all-features` to `cargo install`
required: false
default: '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:
- run: |
set -eu
if ! command -v bash >/dev/null; then
if grep -Eq '^ID=alpine' /etc/os-release; then
printf '::group::Install packages required for cache-cargo-install-action (bash)\n'
# NB: sync with apk_install in pre.sh
if command -v sudo >/dev/null; then
sudo apk --no-cache add bash
elif command -v doas >/dev/null; then
doas apk --no-cache add bash
else
apk --no-cache add bash
fi
printf '::endgroup::\n'
else
printf '::error::cache-cargo-install-action requires bash\n'
exit 1
fi
fi
shell: sh
if: runner.os == 'Linux'
- 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 }}
INPUT_FEATURES: ${{ inputs.features }}
INPUT_NO_DEFAULT_FEATURES: ${{ inputs.no-default-features }}
INPUT_ALL_FEATURES: ${{ inputs.all-features }}
ACTION_USER_AGENT: ${{ github.action_repository }} (${{ github.action_ref }})
- name: Restore Cache
id: cache
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
with:
path: ${{ steps.pre.outputs.path }}
key: ${{ steps.pre.outputs.key }}
- name: Install ${{ inputs.tool }}
run: bash --noprofile --norc "${GITHUB_ACTION_PATH:?}/install.sh"
shell: bash
env:
INPUT_GIT: ${{ steps.pre.outputs.git }}
INPUT_REV: ${{ steps.pre.outputs.rev }}
INPUT_TAG: ${{ steps.pre.outputs.tag }}
INPUT_TOOL: ${{ steps.pre.outputs.tool }}
INPUT_VERSION: ${{ steps.pre.outputs.version }}
INPUT_LOCKED: ${{ steps.pre.outputs.locked }}
INPUT_FEATURES_FLAG: ${{ steps.pre.outputs.features_flag }}
INPUT_NO_DEFAULT_FEATURES_FLAG: ${{ steps.pre.outputs.no_default_features_flag }}
INPUT_ALL_FEATURES_FLAG: ${{ steps.pre.outputs.all_features_flag }}
if: steps.cache.outputs.cache-hit != 'true'