1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
BRANCH=$1
VERSION=$2
if [ -z "$BRANCH" ]
then
echo "A branch is not set."
exit 1
fi
if [ -z "$VERSION" ]
then
echo "The base version is not set."
exit 1
fi
git fetch --tags
if [ "$BRANCH" = "master" ]
then
echo "$VERSION"
exit 0
fi
LABEL="develop"
if [ "$BRANCH" = "stable" ]
then
LABEL="stable"
elif [ "$BRANCH" = "beta" ]
then
LABEL="beta"
fi
for (( VERSION_NUMBER=0; ; VERSION_NUMBER++ ))
do
RESULT_VERSION="$VERSION-$LABEL.$VERSION_NUMBER"
if ! [[ $(git tag -l | grep $RESULT_VERSION) ]]; then
echo "$RESULT_VERSION" | tr / -
break
fi
done