-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·76 lines (61 loc) · 1.85 KB
/
release.sh
File metadata and controls
executable file
·76 lines (61 loc) · 1.85 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env bash
# This will ensure that the script exits if a failure occurs
set -e
if [[ $# != 1 ]]
then
echo "Usage: $0 RELEASE_NUMBER"
echo
echo "Publishes a release to PyPI and GitHub."
exit 1
fi
# This will ensure the user is visually prompted upon failure
trap "echo FAILURE: An error has occured! >&2" EXIT
VERSION=$1
echo "Checking for existence of VERSION file."
if [ -f "./VERSION" ]; then
echo "Found VERSION file."
else
echo "Could not find VERSION file!"
exit 2
fi
OLD_VERSION=`cat ./VERSION`
if [[ "$OLD_VERSION" == "$VERSION" ]]; then
echo "Old version same as new version, skipping commit step."
else
echo "Changing VERSION file, old version: $OLD_VERSION"
echo "$VERSION" > ./VERSION
echo "Creating new commit for version change."
git add ./VERSION
git commit -m "Released $VERSION." -e
echo "Pushing."
git push origin master
fi
echo "Checking for existence of $VERSION tag."
TAGS=`git tag`
if [[ "$TAGS" == *"$VERSION"* ]]; then
echo "$VERSION tag exists locally."
else
# This will launch an editor to create the tag message
echo "$VERSION tag does not exist locally, creating it."
git tag -a $VERSION
echo "Pushing tag."
git push origin $VERSION
fi
echo "Looking for setup.py in current directory..."
if [ -f "./setup.py" ]; then
echo "Found setup.py"
else
echo "Could not find setup.py!"
exit 2
fi
echo "Updating PyPI..."
./setup.py bdist_egg register upload
./setup.py sdist register upload
echo "Deleting ~/.pypirc that stores your password in plaintext..."
rm -f ~/.pypirc
echo "Finished."
echo "This script cannot detect whether uploads to PyPI were succesful, so "
echo "make sure to check the output of the above commands."
# Unset the trap so we don't freak the user out by telling them an error has
# occured when everything went fine.
trap - EXIT