-
Notifications
You must be signed in to change notification settings - Fork 0
/
release_it.sh
executable file
·46 lines (37 loc) · 1.05 KB
/
release_it.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
# check parameters
if [ "$#" -ne 1 ]; then
>&2 echo "Illegal number of parameters"
>&2 echo "usage: ./release_it.sh [major|minor|patch]"
exit 1
fi
# get variables
RELEASE_PART=$1
CURRENT_BRANCH=$(git branch --show-current)
INFO=$(bump2version --list --dry-run "$RELEASE_PART")
if [ "$?" -ne 0 ]; then
>&2 echo "Error while running bump2version, exiting"
exit 1
fi
CURRENT_VERSION=$(echo "$INFO" | grep "current_version" | sed -r s,"^.*=",,)
NEW_VERSION=$(echo "$INFO" | grep "new_version" | sed -r s,"^.*=",,)
# ask
while true; do
read -p "Do you wish to upgrade from $CURRENT_VERSION to $NEW_VERSION? [y/n] " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit 0;;
* ) echo "Please answer yes or no.";;
esac
done
# go to dev and ensure latest version
if [[ $CURRENT_BRANCH != "dev" ]]; then
git checkout dev
fi
git pull
# bump version
bump2version "$RELEASE_PART" --verbose
git push --follow-tags origin dev
# switch back to current branch
if [[ $CURRENT_BRANCH != "dev" ]]; then
git checkout "$CURRENT_BRANCH"
fi