-
Notifications
You must be signed in to change notification settings - Fork 16
/
release.sh
executable file
·44 lines (36 loc) · 1.1 KB
/
release.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
#!/bin/zsh
export RELEASE_TYPE="$1"
export ERROR_MESSAGE="Usage: './release.sh (patch|minor|major)'"
if [ -z "${RELEASE_TYPE}" ]; then
echo "${ERROR_MESSAGE}"
exit 1
fi
if ! [[ "${RELEASE_TYPE}" =~ (patch|minor|major) ]]; then
echo "${ERROR_MESSAGE}"
exit 1
fi
if [[ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]]; then
echo 'Release should be run on master. Exiting.'
exit 1
fi
if [[ -n $(git status -s) ]]; then
echo "There are uncommitted changes. Exiting."
exit 1
fi
if [[ $(git rev-parse HEAD) != $(git rev-parse origin/master) ]]; then
echo 'Local master is not in sync with remote. Exiting.'
exit 1
fi
export NEW_VERSION="$(poetry version ${RELEASE_TYPE} --short)"
git checkout -b "release-${NEW_VERSION}"
git add pyproject.toml
git commit -m "Release ${NEW_VERSION}"
git tag -f ${NEW_VERSION}
git tag -f latest
git push origin -f ${NEW_VERSION}
git push origin -f latest
export NEW_PREPATCH_VERSION="$(poetry version prepatch --short)"
git add pyproject.toml
git commit -m "Bumping to next pre-patch version ${NEW_PREPATCH_VERSION}"
git push
hub pull-request -m "Release ${NEW_VERSION}"