nosqlbench/scripts/get-preview-version.sh

60 lines
1.7 KiB
Bash
Raw 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.
#
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)
2024-08-22 12:29:35 -05:00
if [ -e "$TAG" ]
then
printf "There are no tags attached to the current branch. bailing out\n"
exit 5
fi
2023-01-23 21:18:53 -06:00
if [[ $TAG =~ ([0-9]+)\.([0-9]+)\.([0-9]+)(-preview)? ]]
then
printf "The tag format matches the version, continuing\n" 1>&2
set -- "${BASH_REMATCH[@]}"
TAG_STRING="${@:2:3}"
else
2024-08-22 12:29:35 -05:00
printf "The tag format for '${TAG}' (from revision ${REVISION}) does not match #.#.#-preview form. bailing out\n" 1>&2
2023-01-23 21:18:53 -06:00
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
printf "%s.%s.%s-preview\n" "${@:2:3}"