-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint
More file actions
executable file
·114 lines (92 loc) · 3.25 KB
/
entrypoint
File metadata and controls
executable file
·114 lines (92 loc) · 3.25 KB
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
105
106
107
108
109
110
111
112
113
114
#!/bin/bash
# /github/workspace is where github actions always mounts the repo
# it can't be changed, and this is required to prevent svu from throwing errors
git config --global --add safe.directory /github/workspace
if [[ "${INPUT_CLONE}" == "true" ]]; then
git clone https://github.com/${GITHUB_REPOSITORY} .
elif [[ "${INPUT_UNSHALLOW}" == "true" ]]; then
git fetch --unshallow
fi
CURRENT=$(/bin/svu current)
CURRENT_JSON=$(/bin/svu current --json)
echo "current=${CURRENT}" >> "$GITHUB_OUTPUT"
echo "current_json=${CURRENT_JSON}" >> "$GITHUB_OUTPUT"
if [[ "${INPUT_CMD}" == "current" ]]; then
echo "next=${CURRENT}" >> "$GITHUB_OUTPUT"
echo "next_json=${CURRENT_JSON}" >> "$GITHUB_OUTPUT"
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
ARGS=""
# v3 Inputs
# global flags
# --tag.mode
if [[ "${INPUT_TAGMODE}" != "all" ]] && [[ "${INPUT_TAGMODE}" != "" ]]; then
if [[ "${INPUT_TAGMODE}" == "current-branch" ]]; then
ARGS="${ARGS} --tag.mode=current"
else
ARGS="${ARGS} --tag.mode=${INPUT_TAGMODE}"
fi
fi
# --tag.pattern
if [[ "${INPUT_TAGPATTERN}" != "" ]]; then
ARGS="${ARGS} --tag.pattern=${INPUT_TAGPATTERN}"
fi
# --tag.prefix
if [[ "${INPUT_TAGPREFIX}" != "v" ]]; then
ARGS="${ARGS} --tag.prefix=${INPUT_TAGPREFIX}"
fi
# --verbose
if [[ "${INPUT_VERBOSE}" == "true" ]]; then
ARGS="${ARGS} --verbose"
fi
# cmd-specific flags
# --always
if [[ "${INPUT_CMD}" == "next" ]] && [[ "${INPUT_ALWAYS}" == "true" ]]; then
ARGS="${ARGS} --always"
fi
# --log.directory
if [[ "${INPUT_LOGDIRECTORY}" != "" ]] && ( [[ "${INPUT_CMD}" == "next" ]] || [[ "${INPUT_CMD}" == "prerelease" ]] ); then
ARGS="${ARGS} --log.directory=${LOGDIRECTORY}"
fi
# --metadata
if [[ "${INPUT_CMD}" == "next" ]] && [[ "${INPUT_METADATA}" != "" ]]; then
ARGS="${ARGS} --metadata=${METADATA}"
fi
# --prerelease
if [[ "${INPUT_PRERELEASE}" != "" ]] && ( [[ "${INPUT_CMD}" == "next" ]] || [[ "${INPUT_CMD}" == "prerelease" ]] ); then
ARGS="${ARGS} --prerelease=${INPUT_PRERELEASE}"
fi
# --v0
if [[ "${INPUT_CMD}" == "next" ]] && [[ "${INPUT_V0}" != "false" ]]; then
ARGS="${ARGS} --v0"
fi
# legacy Inputs
if [[ "${INPUT_PATTERN}" != "" ]] && [[ "${INPUT_TAGPATTERN}" == "" ]]; then
ARGS="${ARGS} --tag.pattern=${PATTERN}"
fi
if [[ "${INPUT_PREFIX}" != "" ]] && [[ "${INPUT_TAGPREFIX}" == "v" ]]; then
ARGS="${ARGS} --tag.prefix=${PREFIX}"
fi
if [[ "${INPUT_BUILD}" != "" ]] && [[ "${INPUT_CMD}" == "next" ]] && [[ "${INPUT_METADATA}" == "" ]]; then
ARGS="${ARGS} --metadata=${BUILD}"
fi
if [[ "${INPUT_DIRECTORY}" != "" ]] && [[ "${INPUT_CMD}" == "next" ]] && [[ "${INPUT_LOGDIRECTORY}" == "" ]]; then
ARGS="${ARGS} --log.directory=${DIRECTORY}"
fi
if [[ "${INPUT_FORCEPATCHINCREMENT}" == "true" ]] && [[ "${INPUT_CMD}" == "next" ]] && [[ "${INPUT_ALWAYS}" != "true" ]]; then
ARGS="${ARGS} --always"
fi
NEXT=$(/bin/svu ${INPUT_CMD} ${ARGS})
NEXT_JSON=$(/bin/svu ${INPUT_CMD} --json ${ARGS})
echo "next=${NEXT}" >> "$GITHUB_OUTPUT"
echo "next_JSON=${NEXT_JSON}" >> "$GITHUB_OUTPUT"
if [[ "${NEXT}" == "${CURRENT}" ]]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
if [[ "${INPUT_PUSHTAG}" == "true" ]]; then
git tag "${NEXT}"
git push --tags
fi
fi