forked from cisagov/trustymail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bump_version.sh
executable file
·43 lines (37 loc) · 1.32 KB
/
bump_version.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
#!/usr/bin/env bash
# bump_version.sh (show|major|minor|patch|prerelease|build)
set -o nounset
set -o errexit
set -o pipefail
VERSION_FILE=trustymail/__init__.py
HELP_INFORMATION="bump_version.sh (show|major|minor|patch|prerelease|build|finalize)"
old_version=$(sed -n "s/^__version__ = '\(.*\)'$/\1/p" $VERSION_FILE)
if [ $# -ne 1 ]
then
echo "$HELP_INFORMATION"
else
case $1 in
major|minor|patch|prerelease|build)
new_version=$(python -c "import semver; print(semver.bump_$1('$old_version'))")
echo Changing version from "$old_version" to "$new_version"
sed -i "s/$old_version/$new_version/" $VERSION_FILE
git add $VERSION_FILE
git commit -m"Bump version from $old_version to $new_version"
git push
;;
finalize)
new_version=$(python -c "import semver; print(semver.finalize_version('$old_version'))")
echo Changing version from "$old_version" to "$new_version"
sed -i "s/$old_version/$new_version/" $VERSION_FILE
git add $VERSION_FILE
git commit -m"Finalize version from $old_version to $new_version"
git push
;;
show)
echo "$old_version"
;;
*)
echo "$HELP_INFORMATION"
;;
esac
fi