-
Notifications
You must be signed in to change notification settings - Fork 8
/
action.yaml
86 lines (77 loc) · 2.94 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Install jq
description: |
Installs a version of jq into the job tool cache using simple shell scripts
branding:
icon: copy
color: orange
inputs:
version:
required: false
description: "Version of jq to install"
default: "1.7"
force:
required: false
description: "If 'true', does not check for existing jq installation before continuing."
default: 'false'
outputs:
found:
description: "If 'true', jq was already found on this runner"
value: "${{ steps.jq-check-unix.outputs.found == 'true' || steps.jq-check-windows.outputs.found == 'true' }}"
installed:
description: "If 'true', jq was installed by this action"
value: "${{ inputs.force == 'true' || steps.jq-check-unix.outputs.found == 'false' || steps.jq-check-windows.outputs.found == 'false' }}"
runs:
using: composite
steps:
- name: 'Check for jq - Unix-ish'
id: jq-check-unix
if: (runner.os == 'Linux' || runner.os == 'macOS')
shell: sh +e {0}
# language=sh
run: |
_jq_bin="$(which jq)"
if [ -f "${_jq_bin}" ]; then
echo "found=true" >> $GITHUB_OUTPUT
else
echo "found=false" >> $GITHUB_OUTPUT
fi
- name: 'Install jq - Unix-ish non-1.7'
if: (runner.os == 'Linux' || runner.os == 'macOS') && (inputs.version == '1.5' || inputs.version == '1.6') && (steps.jq-check-unix.outputs.found == 'false' || inputs.force == 'true')
shell: sh
env:
JQ_VERSION: '${{ inputs.version }}'
# language=sh
run: ${GITHUB_ACTION_PATH}/scripts/unixish.sh
- name: 'Install jq - Unix-ish 1.7'
if: (runner.os == 'Linux' || runner.os == 'macOS') && inputs.version == '1.7' && (steps.jq-check-unix.outputs.found == 'false' || inputs.force == 'true')
shell: sh
env:
JQ_VERSION: '${{ inputs.version }}'
# language=sh
run: ${GITHUB_ACTION_PATH}/scripts/unixish-17.sh
- name: 'Check for jq - Windows-ish'
id: jq-check-windows
if: runner.os == 'Windows'
shell: powershell
# language=powershell
run: |
if (Get-Command "jq.exe" -ErrorAction SilentlyContinue)
{
Add-Content $Env:GITHUB_OUTPUT "found=true"
}
else
{
Add-Content $Env:GITHUB_OUTPUT "found=false"
}
- name: 'Install jq - Windows-ish non-1.7'
if: runner.os == 'Windows' && (inputs.version == '1.5' || inputs.version == '1.6') && (steps.jq-check-windows.outputs.found == 'false' || inputs.force == 'true')
shell: powershell
env:
JQ_VERSION: '${{ inputs.version }}'
run: ${{ github.action_path }}\scripts\windowsish.ps1
- name: 'Install jq - Windows-ish 1.7'
if: runner.os == 'Windows' && inputs.version == '1.7' && (steps.jq-check-windows.outputs.found == 'false' || inputs.force == 'true')
shell: powershell
env:
JQ_VERSION: '${{ inputs.version }}'
run: ${{ github.action_path }}\scripts\windowsish-17.ps1