-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
65 lines (57 loc) · 1.99 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
name: sver Action
branding:
icon: code
color: blue
description: sver SemVer (Semantic Versioning 2) parser, bump & utility action with support for version constraints
inputs:
command:
default: ''
description: sver (https://github.com/robzr/sver) command and arguments.
required: false
input:
description: List of input versions, used with filter, max, min, or sort commands.
required: false
input-command:
description: Command to be run, the output will be used in place of the input variable.
required: false
outputs:
output:
description: Output of sver command. JSON/YAML, string or boolean-as-string.
value: ${{ steps.run.outputs.output }}
runs:
using: composite
steps:
- env:
COMMAND: ${{ inputs.command }}
INPUT: ${{ inputs.input }}
INPUT_FILE: /dev/null
INPUT_COMMAND: ${{ inputs.input-command }}
SVER_BIN: ${{ github.action_path }}/sver
id: run
run: |
# steps.run
if ${{ inputs.input-command == '' && 'false' || 'true' }} ; then
INPUT_FILE=$(mktemp)
echo '::group::Run input-command'
${{ inputs.input-command == '' && true || inputs.input-command }} | tee "${INPUT_FILE}"
echo '::endgroup::'
elif ${{ inputs.input == '' && 'false' || 'true' }} ; then
INPUT_FILE=$(mktemp)
cat >>"${INPUT_FILE}" <<_EOF_SVER_ACTION_
${{ inputs.input }}
_EOF_SVER_ACTION_
fi
OUTPUT_FILE=$(mktemp)
RETURN_VALUE='true'
echo '::group::sver output'
cat "$INPUT_FILE" | "$SVER_BIN" ${{ inputs.command }} >"${OUTPUT_FILE}" || RETURN_VALUE=false
cat "$OUTPUT_FILE"
echo '::endgroup::'
if [ $(wc -c < "$OUTPUT_FILE") -eq 0 ] ; then
echo "output=${RETURN_VALUE}" >>"${GITHUB_OUTPUT}"
else
echo 'output<<_EOF_' >>"${GITHUB_OUTPUT}"
cat "$OUTPUT_FILE" >>"${GITHUB_OUTPUT}"
echo '_EOF_' >>"${GITHUB_OUTPUT}"
fi
shell: bash