-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathpypi_release.sh
More file actions
executable file
·61 lines (46 loc) · 1.13 KB
/
Copy pathpypi_release.sh
File metadata and controls
executable file
·61 lines (46 loc) · 1.13 KB
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
57
58
59
60
61
#!/usr/bin/env bash
OPTIND=1 # Reset in case getopts has been used previously in the shell.
USAGE="PyPi release script.
Usage: checkout [-u][-p]
-u pypi user
-p pypi password
"
while getopts "u:p:h?:" opt; do
case $opt in
u) user=$OPTARG
;;
p) password=$OPTARG
;;
h) echo $USAGE
exit 0 ;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
if [ -z "$user" ]; then
echo "PyPi user is required."
exit 1
fi
if [ -z "$password" ]; then
echo "PyPi password is required."
exit 1
fi
upload_pypi() {
rm -rf ./dist
./setup.py clean
./setup.py bdist_egg bdist_wheel dist_info upload -r pypi
}
BRANCH=$(git rev-parse --abbrev-ref HEAD)
VERSION=$(python ./bump_version.py)
LAST_LOG=$(git log -1 --pretty=%B)
MESSAGE="build: bump patch due to build."
if [[ $LAST_LOG =~ $MESSAGE ]]; then
echo "last commit was result of a build."
# exit 0
fi
git add . --all && git commit -m "$MESSAGE"
git tag $VERSION -m "$MESSAGE"
if [ \( $BRANCH == HEAD \) -o \( $BRANCH == master \) ]; then
git push origin HEAD:master
upload_pypi
fi