forked from frenck/action-setup-yq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
62 lines (53 loc) · 1.67 KB
/
action.yaml
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
---
name: "Frenck's yq setup"
description: 🚀 Frenck's GitHub Action for setting up yq.
author: frenck
branding:
color: red
icon: thumbs-up
inputs:
version:
required: false
description: The version of yq to install
default: latest
outputs:
version:
description: The version of yq that was installed
value: ${{ steps.version.outputs.version }}
runs:
using: composite
steps:
- id: version
shell: bash
run: |
version="v$( echo '${{ inputs.version }}' | sed s/^v//)"
if [[ "${{ inputs.version }}" == "latest" ]]; then
version=$(curl -s https://api.github.com/repos/mikefarah/yq/releases/latest | jq -r '.tag_name')
fi
if [[ "$version" == "null" ]]; then
exit 1;
fi
echo "version=${version}" >> "$GITHUB_OUTPUT"
- shell: bash
run: |
echo "Installing yq ${{ steps.version.outputs.version }}..."
if [[ "${{ runner.os }}" == "Linux" ]]; then
executable="yq_linux_amd64"
elif [[ "${{ runner.os }}" == "Windows" ]]; then
executable="yq_windows_386.exe"
elif [[ "${{ runner.os }}" == "macOS" ]]; then
executable="yq_darwin_amd64"
fi
dest="${RUNNER_TEMP}/yq/yq"
if [[ "${{ runner.os }}" == "Windows" ]]; then
dest="${dest}.exe"
fi
mkdir -p "$(dirname ${dest})"
curl \
-L \
"https://github.com/mikefarah/yq/releases/download/${{ steps.version.outputs.version }}/${executable}" \
--output "$dest"
if [[ "${{ runner.os }}" != "Windows" ]]; then
chmod +x "${dest}"
fi
echo "$(dirname ${dest})" >> $GITHUB_PATH