-
Notifications
You must be signed in to change notification settings - Fork 7
/
.travis_deploy.sh
executable file
·56 lines (50 loc) · 1.5 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
#!/bin/bash
# only deploy builds for a release_<sematic-version>_RC?? tag to testpypi
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' ] || [ "version = $TAG2" != $(cat singlet/_version.py) ]; then
echo 'No release tag or wrong version, exit'
exit 0;
fi
SINGLET_VERSION=$TAG2
# For now deploy only Linux Python 3.6 (it's pure Python)
if [ $TRAVIS_OS_NAME != 'linux' ]; then
echo 'Not linux, 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
echo "Deploying to pip using twine"
echo "TWINE_REPOSITORY=$TWINE_REPOSITORY"
echo "TWINE_USERNAME=$TWINE_USERNAME"
echo "TWINE_PASSWORD=$TWINE_PASSWORD"
pip --version
pip install twine
# Build source
python setup.py sdist --dist-dir dist/
# Upload source
twine upload --repository-url "${TWINE_REPOSITORY}" -u "${TWINE_USERNAME}" -p "${TWINE_PASSWORD}" dist/singlet-${SINGLET_VERSION}.tar.gz