nosqlbench/scripts/get-release-version.sh

69 lines
1.8 KiB
Bash
Raw Permalink Normal View History

2023-01-23 15:24:52 -06:00
#!/bin/bash
#
2024-10-30 16:12:21 -05:00
# Copyright (c) nosqlbench
2023-01-23 15:24:52 -06:00
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
2023-01-26 00:53:32 -06:00
if [ "$1" == "-n" ]
then numeric=true
elif [ "$1" == "-s" ]
then short=true
fi
2023-01-23 15:24:52 -06:00
set -e
export REVISION=$(mvn help:evaluate -Dexpression=revision -q -DforceStdout)
2023-01-23 21:18:53 -06:00
if [[ $REVISION =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)-SNAPSHOT$ ]]
then
printf "The revision matches the format, continuing\n" 1>&2
set -- "${BASH_REMATCH[@]}"
VERSION_STRING="${@:2:3}"
else
printf "The revision format for '${REVISION}' does not match #.#.#-SNAPSHOT form. bailing out\n"
exit 3
fi
export TAG=$(git describe --exact-match --tags)
if [[ $TAG =~ ([0-9]+)\.([0-9]+)\.([0-9]+)(-release)? ]]
then
printf "The tag format matches the version, continuing\n" 1>&2
set -- "${BASH_REMATCH[@]}"
TAG_STRING="${@:2:3}"
else
printf "The tag format for '${TAG}' does not match #.#.#-release form. bailing out\n" 1>&2
exit 4
fi
printf "version(${VERSION_STRING}) tag(${TAG_STRING})\n" 1>&2
if [ "${VERSION_STRING}" == "${TAG_STRING}" ]
then
printf "version and tag match, continuing\n" 1>&2
else
printf "version and tag do not match: bailing out\n" 1>&2
exit 5
fi
2023-01-26 00:53:32 -06:00
if [ "$numeric" == "true" ]
then
printf "%s.%s.%s\n" "${@:2:3}"
elif [ "$short" == "true" ]
then
printf "%s.%s\n" "${@:2:2}"
else
printf "%s.%s.%s-release\n" "${@:2:3}"
fi
2023-01-23 21:18:53 -06:00