-
Notifications
You must be signed in to change notification settings - Fork 7
/
action.yml
48 lines (46 loc) · 1.62 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
# action.yml
name: 'Run SDKMAN!'
author: 'SDKMAN!'
branding:
icon: 'command'
color: 'red'
description: 'Download the sdk you want to install'
inputs:
candidate:
description: 'The name of the candidate to install'
required: false
version:
description: 'The version of the candidate to install'
required: false
outputs:
file:
description: 'Filename of the downloaded archive.'
value: ${{ steps.sdkman.outputs.file }}
runs:
using: 'composite'
steps:
- id: sdkman
shell: bash
run: |
if [[ $RUNNER_OS == 'Linux' || $RUNNER_OS == 'macOS' ]]; then
export SDKMAN_DIR="$HOME/.sdkman" && curl -s "https://get.sdkman.io?rcupdate=false" | bash
if [[ -z "${{ inputs.candidate }}" && -z "${{ inputs.version }}" ]]; then
source $HOME/.sdkman/bin/sdkman-init.sh && sdk env install
else
candidate=${{ inputs.candidate }}
version=${{ inputs.version }}
source $HOME/.sdkman/bin/sdkman-init.sh && sdk install $candidate $version
fi
for child_dir in $(find "$SDKMAN_DIR/candidates" -mindepth 1 -maxdepth 1 -type d); do
echo "$child_dir/current/bin" >> $GITHUB_PATH
done
echo "file=" >> $GITHUB_OUTPUT
else
candidate=${{ inputs.candidate }}
version=${{ inputs.version }}
platform=$(uname)
base_name="${candidate}-${version}"
zip_output="$base_name.zip"
curl -L -o $zip_output https://api.sdkman.io/2/broker/download/$candidate/$version/$platform
echo "file=$zip_output" >> $GITHUB_OUTPUT
fi