-
Notifications
You must be signed in to change notification settings - Fork 18
/
.publish.sh
executable file
·32 lines (27 loc) · 1.14 KB
/
.publish.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
#!/usr/bin/env bash
# Deploys a Python library or application
product=$(echo $TRAVIS_TAG | awk -F '=' '{print $1}')
version=$(echo $TRAVIS_TAG | awk -F '=' '{print $2}')
if [ -z "$product" ]; then
echo "Could not find name of product in TRAVIS_TAG: $TRAVIS_TAG";
exit -1
fi
if [ -z "$version" ]; then
echo "Could not find version of product in TRAVIS_TAG: $TRAVIS_TAG";
exit -1
fi
echo "Deploying $product, version $version..."
cd $product || { echo "Project $product does not exist in this repo"; exit -1; }
# check that the version in the tag and in setup.cfg match
sed 's/ //g' setup.cfg | grep "^version=$version" || { \
echo "Version in tag ($version) does not match version in setup.cfg \
($(sed 's/ //g' setup.cfg | grep '^version=' | awk -F '=' '{print $2}'))"; \
exit -1; }
# build
python setup.py clean sdist || { echo "Errors building $product"; exit -1; }
# upload to pypi
echo "Publish on pypi"
twine upload dist/* || { echo "Errors publishing $TRAVIS_TAG"; exit -1; }
# check version available
pip uninstall -y $product
pip install --upgrade --pre $product==$version || { echo "$TRAVIS_TAG not installed on pypi" ; exit -1; }