forked from slf-dot-ch/snowmicropyn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish_to_pypi.sh
executable file
·65 lines (51 loc) · 1.39 KB
/
publish_to_pypi.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
#!/usr/bin/env sh
# Stop script on error
set -e
REPO_URL=https://github.com/slf-dot-ch/snowmicropyn
case $# in
1)
TAG=$1
SYSTEM="TEST"
;;
2)
TAG=$1
if [ $2 == "LIVE" ]
then
SYSTEM="LIVE"
else
echo "Second argument not equal LIVE, refusing publishing"
exit 1
fi
;;
*)
echo "Usage: `basename "$0"` <tag> [LIVE]";
echo "Publishing to PyPI live index when string LIVE is provided, otherwise publish to test index";
exit 1
;;
esac
read -p "Publishing release with tag ${TAG} to ${SYSTEM} index on PyPI. Press enter to continue"
RELEASE_DIR=RELEASE_${TAG}
CLONE="git clone ${REPO_URL} --branch ${TAG} --single-branch --depth=1 --quiet ${RELEASE_DIR}"
echo "Cloning: ${CLONE}"
`${CLONE}`
cd ${RELEASE_DIR}
GET_HASH="git rev-list -n 1 ${TAG}"
echo "Getting hash: ${GET_HASH}"
HASH=`${GET_HASH}`
echo "Hash is " ${HASH}
HASHFILE=snowmicropyn/githash
echo "Writing hash to file ${HASHFILE}"
echo ${HASH} > ${HASHFILE}
echo "Building source distribution..."
python3 setup.py sdist
echo "Building pure python wheel..."
python3 setup.py bdist_wheel
if [ ${SYSTEM} == "LIVE" ]
then
echo "Uploading to PyPI index..."
twine upload dist/*
else
echo "Uploading to PyPI test index..."
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
fi
echo "Publishing snowmicropyn ${TAG} to ${SYSTEM} PyPI complete. Have a beer."