File tree 3 files changed +44
-1
lines changed
3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -206,6 +206,21 @@ version=$( strip_snapshot_suffix "1.2.3-SNAPSHOT" )
206
206
version=$( strip_snapshot_suffix "1.2.3.BUILD-SNAPSHOT" )
207
207
----
208
208
209
+
210
+
211
+ ==== get_next_release
212
+ Get the release version based on a given snapshot version.
213
+
214
+ The following call will set `next` to `1.0.0.RELEASE`.
215
+
216
+ [source,bash]
217
+ ----
218
+ next=$( get_next_milestone_release "1.0.0.BUILD-SNAPSHOT" )
219
+ ----
220
+
221
+ TIP: Version numbers in the form `1.0.0-SNAPSHOT` and `1.0.0.BUILD-SNAPSHOT` are both supported
222
+
223
+
209
224
==== get_next_milestone_release / get_next_rc_release
210
225
Get the next milestone or release candidate version based on a given version and existing git tags.
211
226
These methods allow preview releases to be published, without needing to directly store the release number.
Original file line number Diff line number Diff line change @@ -67,6 +67,21 @@ get_next_rc_release() {
67
67
get_next_tag_based_release " $1 " " RC"
68
68
}
69
69
70
+ # Get the next release for the given number
71
+ get_next_release () {
72
+ [[ -n $1 ]] || { echo " missing get_next_release() version argument" >&2 ; return 1; }
73
+ if [[ $1 =~ ^(.* )\. BUILD-SNAPSHOT$ ]]; then
74
+ local join=" ."
75
+ else
76
+ local join=" -"
77
+ fi
78
+ local version
79
+ local result
80
+ version=$( strip_snapshot_suffix " $1 " )
81
+ result=" ${version}${join} RELEASE"
82
+ echo $result
83
+ }
84
+
70
85
# Get the next milestone or RC release for the given number by inspecting current tags
71
86
get_next_tag_based_release () {
72
87
[[ -n $1 ]] || { echo " missing get_next_tag_based_release() version argument" >&2 ; return 1; }
Original file line number Diff line number Diff line change @@ -84,6 +84,19 @@ source "$PWD/concourse-java.sh"
84
84
assert_output " 2.0.0.B3"
85
85
}
86
86
87
+ @test " get_next_release() should return next release version" {
88
+ run get_next_release " 1.5.0.BUILD-SNAPSHOT"
89
+ assert_output " 1.5.0.RELEASE"
90
+ run get_next_release " 1.5.0-SNAPSHOT"
91
+ assert_output " 1.5.0-RELEASE"
92
+ }
93
+
94
+ @test " get_next_release() when has no version should fail" {
95
+ run get_next_release
96
+ assert [ " $status " -eq 1 ]
97
+ assert_output " missing get_next_release() version argument"
98
+ }
99
+
87
100
mock_git_repo () {
88
101
local tmpdir=$( mktemp -d $BATS_TMPDIR /gitrepo.XXXXXX) >&2
89
102
mkdir -p " $tmpdir " >&2
@@ -96,4 +109,4 @@ mock_git_repo() {
96
109
git tag " $tag " >&2
97
110
done
98
111
echo " $tmpdir "
99
- }
112
+ }
You can’t perform that action at this time.
0 commit comments