-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
104 lines (92 loc) · 2.91 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
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
98
99
100
101
102
103
104
name: 'alr install'
description: 'Install using `alr install`'
author: 'Alire Project'
inputs:
crates:
description: 'Crates to install, accepts version sets, e.g.: hello^2'
required: true
default: ''
prefix:
description: Location for the installation, will contain `<prefix>/bin` and so on
required: false
default: alire_prefix
force:
description: use `alr --force` during install
required: false
default: false
add_to_path:
description: Whether to add the prefix to path
required: false
default: true
clean:
description: Whether to remove alr afterwards, if it wasn't originally installed
required: false
default: true
cache:
description: Whether to reuse a cached previous install
required: false
default: true
runs:
using: "composite"
steps:
- name: Find alr in path
id: find-alr
shell: bash
run: |
which alr && echo "available=true" >> $GITHUB_OUTPUT || echo "available=false" >> $GITHUB_OUTPUT
- name: Set up alr
if: steps.find-alr.outputs.available != 'true'
uses: alire-project/setup-alire@v3
with:
cache: ${{inputs.cache}}
- name: Prepare --force
id: force
shell: bash
run: |
if [[ "${{inputs.force}}" != "false" ]]; then
echo "force=--force" >> $GITHUB_OUTPUT
else
echo "force=" >> $GITHUB_OUTPUT
fi
- name: Prepare cache id
id: find-versions
shell: bash
run: |
versions=""
for crate in ${{inputs.crates}}; do
versions+=":"$(alr show ${crate} | head -1 | cut -f1 -d:)
done
echo Versions are: $versions
echo "milestones=$versions" >> $GITHUB_OUTPUT
- name: Reuse cached installation
if: inputs.cache == 'true'
id: cache-install
uses: actions/cache@v3
with:
path: |
${{inputs.prefix}}
key: '[alr-install][${{runner.os}}][${{inputs.prefix}}][${{steps.find-versions.outputs.milestones}}]'
- name: Run `alr install`
if: inputs.cache != 'true' || steps.cache-install.outputs.cache-hit != 'true'
shell: bash
run: |
alr -d ${{steps.force.outputs.force}} install ${{inputs.crates}} --prefix ${{inputs.prefix}}
- name: Show prefix info
shell: bash
run: |
alr install --prefix ${{inputs.prefix}} --info
- name: Add to path (Windows)
if: inputs.add_to_path == 'true' && runner.os == 'Windows'
shell: pwsh
run: |
$Target = Resolve-Path ${{inputs.prefix}}\bin
Add-Content $env:GITHUB_PATH $Target
- name: Add to path (!Windows)
if: inputs.add_to_path == 'true' && runner.os != 'Windows'
shell: bash
run: |
readlink -f "${{inputs.prefix}}/bin" >> $GITHUB_PATH
- name: Cleanup
if: inputs.clean == 'true' && steps.find-alr.outputs.available != 'true'
shell: bash
run: rm -rf alire_install