forked from lindenlab/caddy-s3-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag.sh
executable file
·57 lines (47 loc) · 1.07 KB
/
tag.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
BRANCH=$DRONE_COMMIT_BRANCH
if [ "$BRANCH" = "" ]; then
BRANCH=$(git rev-parse --abbrev-ref HEAD)
fi
calc_version () {
VERSION_FILE=$1
DIR=$(dirname $VERSION_FILE)
if [ "$DIR" = "." ]; then
MODULE_PATH=
else
MODULE_PATH=$DIR/
fi
echo $MODULE_PATH"v$(cat $VERSION_FILE)"
}
if [ "$1" = "check_version" ]; then
shift
for var in "$@"
do
VERSION=$(calc_version $var)
VER_EXIST=$(git tag -l $VERSION)
echo $VER_EXIST
if [ "$DRONE_COMMIT_BRANCH" != master ] && [ -n "$VER_EXIST" ]; then echo "Need to update $var - exiting" && exit 1; fi
done
exit
fi
git checkout $BRANCH
git pull origin $BRANCH
for var in "$@"
do
VERSION=$(calc_version $var)
if [ "$BRANCH" != "master" ]; then
git describe --match "$VERSION-pre.*" --abbrev=0 HEAD --tags 2> /dev/null
COUNTER=1
while [ $COUNTER -lt 15 ]; do
tag="$VERSION-pre.$COUNTER"
git describe --match $tag --abbrev=0 HEAD --tags 2> /dev/null
if [ $? != 0 ]; then
break;
fi
let COUNTER=COUNTER+1
done
VERSION=$tag
fi
git tag $VERSION
done
git push --tags origin $BRANCH