forked from oceanprotocol/ocean.py
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bumpversion.sh
executable file
·41 lines (35 loc) · 943 Bytes
/
bumpversion.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
#!/bin/bash
##
## Copyright 2022 Ocean Protocol Foundation
## SPDX-License-Identifier: Apache-2.0
##
set -x
set -e
usage(){
echo "Usage: $0 {major|minor|patch} [--tag]"
exit 1
}
if ! [ -x "$(command -v bumpversion)" ]; then
echo 'Error: bumpversion is not installed.' >&2
exit 1
elif ! git diff-index --quiet HEAD -- >/dev/null 2>&1; then
echo 'There are local changes in your the git repository. Please commit or stash them before bumping version.' >&2
exit 1
fi
if [ "$#" -lt 1 ]; then
echo "Illegal number of parameters"
usage
elif [[ $1 != 'major' && $1 != 'minor' && $1 != 'patch' ]]; then
echo 'First argument must be {major|minor|patch}'
usage
fi
if [[ $2 == '--tag' ]]; then
if git branch --contains $(git rev-parse --verify HEAD) | grep -E 'main'; then
eval "bumpversion --tag --commit $1"
else
echo "Only main tags can be tagged"
exit 1
fi
else
eval "bumpversion --no-tag $1"
fi