File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed
Expand file tree Collapse file tree 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" )
206206version=$( strip_snapshot_suffix "1.2.3.BUILD-SNAPSHOT" )
207207----
208208
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+
209224==== get_next_milestone_release / get_next_rc_release
210225Get the next milestone or release candidate version based on a given version and existing git tags.
211226These 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() {
6767 get_next_tag_based_release " $1 " " RC"
6868}
6969
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+
7085# Get the next milestone or RC release for the given number by inspecting current tags
7186get_next_tag_based_release () {
7287 [[ -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"
8484 assert_output " 2.0.0.B3"
8585}
8686
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+
87100mock_git_repo () {
88101 local tmpdir=$( mktemp -d $BATS_TMPDIR /gitrepo.XXXXXX) >&2
89102 mkdir -p " $tmpdir " >&2
@@ -96,4 +109,4 @@ mock_git_repo() {
96109 git tag " $tag " >&2
97110 done
98111 echo " $tmpdir "
99- }
112+ }
You can’t perform that action at this time.
0 commit comments