-
Notifications
You must be signed in to change notification settings - Fork 3
/
push_python_package_pypi.sh
executable file
·52 lines (47 loc) · 1.05 KB
/
push_python_package_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
#!/usr/bin/env bash
#
# Push Package To Repository
#
# Example Call:
# ./push.sh --pypi=pypi
#
PYPI="pypi"
USERNAME=""
PASSWORD=""
BUILD_DIR="./dist/*"
# Parse CLI Arguments
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--pypi=*)
PYPI="${1#*=}"
shift
;;
--username=*)
USERNAME="${1#*=}"
shift
;;
--password=*)
PASSWORD="${1#*=}"
shift
;;
*)
shift
;;
esac
done
echo "$(date +%c): PyPi = ${PYPI}"
if [ -z "$(ls -A ${BUILD_DIR})" ]; then
echo "$(date +%c): Build Dir is Empty, Nothing to Push. Maybe need to Build First?"
exit 1
fi
echo "$(date +%c): Pushing Pushing Package (${BUILD_DIR}) to ${REPOSITORY}"
if ([ -z "${USERNAME}" ] || [ -z "${PASSWORD}" ])
then
echo "$(date +%c): No Username, Pushing without"
twine upload --repository=${PYPI} ${BUILD_DIR}
else
echo "$(date +%c): Pushing with Specified User: ${USERNAME}"
twine upload --repository=${PYPI} --username=${USERNAME} --password=${PASSWORD} ${BUILD_DIR}
fi