-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.travis_deploy.sh
executable file
·73 lines (66 loc) · 2.04 KB
/
.travis_deploy.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
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
#!/bin/bash
# deploy builds for a release_<semantic-version>_RC?? tag to testpypi
# e.g. release_0.2_RC1
# deploy builds for a release_<semantic-version> to production pypi (careful with those!)
# e.g. release_0.3
#
# NOTE: the env variables TWINE_USERNAME, TWINE_PASSWORD_PYPI, TWINE_PASSWORD_TESTPYPI
# need to be set in the Travis CI settings. Those strings need escaping from bash, so
# if you have e.g. backslashes in your password you need to escape them then typing on the
# Travis settings page.
if [ -z $TRAVIS_TAG ]; then
echo 'No TRAVIS_TAG, exit'
exit 0
fi
TAG1=$(echo $TRAVIS_TAG | cut -f1 -d_)
TAG2=$(echo $TRAVIS_TAG | cut -f2 -d_)
TAG3=$(echo $TRAVIS_TAG | cut -f3 -d_)
if [ -z $TAG2 ]; then
echo 'No TAG2, exit'
exit 0;
fi
if [ $TAG1 != 'release' ]; then
echo 'Not a release tag, exit'
exit 0;
fi
VERSIONSETUP=$(grep 'version=' setup.py | sed 's/^\s*version="\(.*\)",\s*$/\1/')
if [ $TAG2 != $VERSIONSETUP ]; then
echo "Wrong version (TAG=$TAG2, setup.py=$VERSIONSETUP), exit"
exit 0;
fi
if [ $TRAVIS_PYTHON_VERSION != '3.6' ]; then
echo "Not python 3.6, exit"
exit 0;
fi
# deploy onto pypitest unless you have no RC
if [ -z $TAG3 ]; then
TWINE_PASSWORD=${TWINE_PASSWORD_PYPI}
TWINE_REPOSITORY='https://upload.pypi.org/legacy/'
echo 'Deploying to production pypi'
elif [ ${TAG3:0:2} == 'RC' ]; then
TWINE_PASSWORD=${TWINE_PASSWORD_TESTPYPI}
TWINE_REPOSITORY='https://test.pypi.org/legacy/'
echo 'Deploying to testpypi'
else
echo "Tag not recognized: $TRAVIS_TAG"
exit 1
fi
# Build source dir
python setup.py sdist
echo "Contents of 'dist':"
ls dist
# TODO: rename file (Pyi hates same-naming)
if [ -z $TAG3 ]; then
echo "Production version, no renaming"
SDIST_FN=dist/seqanpy-"${TAG2}".tar.gz
else
echo "Testing version, renaming..."
SDIST_FN=dist/seqanpy-"${TAG2}_${TAG3}".tar.gz
mv dist/seqanpy-"${TAG2}".tar.gz "${SDIST_FN}"
fi
echo "${SDIST_FN}"
# Install twine
pip --version
pip install twine
# Upload
twine upload --repository-url "${TWINE_REPOSITORY}" -u "${TWINE_USERNAME}" -p "${TWINE_PASSWORD}" "${SDIST_FN}"