Skip to content

Commit 2b09dd2

Browse files
authored
Merge pull request #13 from AlexAtkinson/feature/add-always-iterate-flag
Feature/add always iterate flag
2 parents 8644480 + 60f0915 commit 2b09dd2

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

action.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ inputs:
99
description: "Forces a re-evaluation of the entire git history."
1010
required: false
1111
default: 'false'
12+
force-patch-increment:
13+
description: "Forces a PATCH increment if no other increment detected. NOTE: This is intended for development purposes only."
14+
required: false
15+
default: 'false'
1216
outputs:
1317
new-version:
1418
description: "New Version"
@@ -33,9 +37,25 @@ runs:
3337
cd $GITHUB_WORKSPACE
3438
opt=''
3539
[[ "${{ inputs.force-re-evaluate }}" == 'true' ]] && opt='-f'
40+
[[ "${{ inputs.force-re-evaluate }}" == 'true' ]] && opt='-p'
3641
new_version="$(${{ github.action_path }}/scripts/detectNewVersion.sh $opt)"
3742
echo "new-version=$new_version" | tee $GITHUB_OUTPUT
38-
[[ "$new_version" =~ "ERROR" ]] && exit 1 || true
43+
if [[ "$new_version" =~ "570" ]]; then
44+
echo -e "\e[01;31mERROR\e[00m: 570 - Invalid argument!"
45+
exit 1 || true
46+
fi
47+
if [[ "$new_version" =~ "590" ]]; then
48+
echo -e "\e[01;31mFATAL\e[00m: 501 - This is not a git repository!"
49+
exit 1 || true
50+
fi
51+
if [[ "$new_version" =~ "591" ]]; then
52+
echo -e "\e[01;31mERROR\e[0m: 591 - Unsupported origin host."
53+
exit 1 || true
54+
fi
55+
if [[ "$new_version" =~ "599" ]]; then
56+
echo -e "\e[01;31mERROR\e[00m: 599 - No feature, enhancement, fix, bugfix, hotfix, or ops branches detected!"
57+
exit 1 || true
58+
fi
3959
shell: bash
4060

4161
# See github contexts for more like github.action_path.

scripts/detectNewVersion.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ DESCRIPTION
4444
4545
-f Forces a re-evaluation of the entire git history.
4646
47+
-p Increments PATCH version on _every_ run.
48+
WARN: This is intended development use only.
49+
4750
EXAMPLES
4851
The following detects the new version for the repo.
4952
@@ -64,15 +67,15 @@ printHelp() {
6467
# --------------------------------------------------------------------------------------------------
6568

6669
if ! git rev-parse --git-dir > /dev/null 2>&1; then
67-
echo -e "\e[01;31mFATAL\e[00m: This is not a git repository!\n"
70+
echo -e "\e[01;31mFATAL\e[00m: 590 - This is not a git repository!\n"
6871
fi
6972

7073
# --------------------------------------------------------------------------------------------------
7174
# Arguments
7275
# --------------------------------------------------------------------------------------------------
7376

7477
OPTIND=1
75-
while getopts "he:vf" opt; do
78+
while getopts "he:vfp" opt; do
7679
case $opt in
7780
h)
7881
printHelp
@@ -89,8 +92,11 @@ while getopts "he:vf" opt; do
8992
f)
9093
arg_f='set'
9194
;;
95+
p)
96+
arg_p='set'
97+
;;
9298
*)
93-
echo -e "\e[01;31mERROR\e[00m: Invalid argument!"
99+
echo -e "\e[01;31mERROR\e[00m: 570 - Invalid argument!"
94100
printHelp
95101
if [[ "$sourced" == 0 ]]; then
96102
exit 0
@@ -147,7 +153,7 @@ case "$origin_host" in
147153
field=1
148154
;;
149155
*)
150-
echo -e "\e[01;31mERROR\e[0m: Unsupported origin host."
156+
echo -e "\e[01;31mERROR\e[0m: 591 - Unsupported origin host."
151157
exit 1
152158
;;
153159
esac
@@ -198,7 +204,7 @@ if [[ -n $arg_f ]]; then
198204
true
199205
else
200206
if [[ -z $incrementMajor && -z $count_feature && -z $count_enhancement && -z $count_fix && -z $count_bugfix && -z $count_hotfix && -z $count_ops ]]; then
201-
echo -e "\e[01;31mERROR\e[00m: No feature, enhancement, fix, bugfix, hotfix, or ops branches detected!"
207+
echo -e "\e[01;31mERROR\e[00m: 599 - No feature, enhancement, fix, bugfix, hotfix, or ops branches detected!"
202208
exit 1 # For GH Actions
203209
if [[ "$sourced" == 0 ]]; then
204210
exit 1
@@ -228,6 +234,10 @@ elif [[ -n $count_fix || -n $count_bugfix || -n $count_hotfix || -n $count_ops ]
228234
[[ -n $count_bugfix ]] && newVersionPatch=$((newVersionPatch + count_bugfix))
229235
[[ -n $count_hotfix ]] && newVersionPatch=$((newVersionPatch + count_hotfix))
230236
[[ -n $count_ops ]] && newVersionPatch=$((newVersionPatch + count_ops))
237+
elif [[ -n $arg_p && -z $incrementMajor && -z $count_feature && -z $count_enhancement && -z $count_fix && -z $count_bugfix && -z $count_hotfix && -z $count_ops ]]; then
238+
newVersionMajor=$lastVersionMajor
239+
newVersionMinor=$lastVersionMinor
240+
newVersionPatch=$((lastVersionPatch + 1))
231241
fi
232242

233243
newVersion=$(/usr/bin/env bash -c "${dir}/validateSemver.sh -9p full $newVersionMajor.$newVersionMinor.$newVersionPatch")
@@ -238,4 +248,4 @@ if [[ -n $arg_e ]]; then
238248
export export_var
239249
else
240250
echo "$newVersion"
241-
fi
251+
fi

0 commit comments

Comments
 (0)