Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,19 @@ version=$( strip_snapshot_suffix "1.2.3-SNAPSHOT" )
version=$( strip_snapshot_suffix "1.2.3.BUILD-SNAPSHOT" )
----

==== get_next_release
Get the release version based on a given snapshot version.

The following call will set `next` to `1.0.0.RELEASE`.

[source,bash]
----
next=$( get_next_milestone_release "1.0.0.BUILD-SNAPSHOT")
----

TIP: Version numbers in the form `1.0.0-SNAPSHOT` and `1.0.0.BUILD-SNAPSHOT` are both supported


==== get_next_milestone_release / get_next_rc_release
Get the next milestone or release candidate version based on a given version and existing git tags.
These methods allow preview releases to be published, without needing to directly store the release number.
Expand Down
15 changes: 15 additions & 0 deletions concourse-java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ set_revision_to_pom() {
sed -ie "s|<revision>.*</revision>|<revision>${1}</revision>|" pom.xml > /dev/null
}

# Get the next release for the given number
get_next_release() {
[[ -n $1 ]] || { echo "missing get_next_release() version argument" >&2; return 1; }
if [[ $1 =~ ^(.*)\.BUILD-SNAPSHOT$ ]]; then
local join="."
else
local join="-"
fi
local version
local result
version=$( strip_snapshot_suffix "$1" )
result="${version}${join}RELEASE"
echo $result
}

# Get the next milestone release for the given number by inspecting current tags
get_next_milestone_release() {
[[ -n $1 ]] || { echo "missing get_next_milestone_release() version argument" >&2; return 1; }
Expand Down
13 changes: 13 additions & 0 deletions test/get_next_release.bats
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ source "$PWD/concourse-java.sh"
assert_output "2.0.0.B3"
}

@test "get_next_release() should return next release version" {
run get_next_release "1.5.0.BUILD-SNAPSHOT"
assert_output "1.5.0.RELEASE"
run get_next_release "1.5.0-SNAPSHOT"
assert_output "1.5.0-RELEASE"
}

@test "get_next_release() when has no version should fail" {
run get_next_release
assert [ "$status" -eq 1 ]
assert_output "missing get_next_release() version argument"
}

mock_git_repo() {
local tmpdir=$(mktemp -d $BATS_TMPDIR/gitrepo.XXXXXX) >&2
mkdir -p "$tmpdir" >&2
Expand Down