You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.1 KiB
84 lines
2.1 KiB
#!/bin/sh - |
|
|
|
_FALSE=0 |
|
_TRUE=1 |
|
__ScriptName="publish.sh" |
|
|
|
username="__token__" |
|
test_token=`cat test.token` |
|
pypi_token=`cat pypi.token` |
|
|
|
#-------------------------------------------------------------------------------------------------- |
|
# Handle command line arguments |
|
#-------------------------------------------------------------------------------------------------- |
|
_USERNAME="__token__" |
|
_TOKEN="" |
|
_TESTREPO=$_FALSE |
|
PTYPE="test" |
|
|
|
|
|
#--- FUNCTION ----------------------------------------------------------------------------------- |
|
# NAME: __usage |
|
# DESCRIPTION: Display usage information. |
|
#-------------------------------------------------------------------------------------------------- |
|
__usage() { |
|
cat << EOT |
|
Usage : ${__ScriptName} [options] <publish-type> |
|
Options: |
|
-h Display this help |
|
Publish types: |
|
- pypi Publish to pypi |
|
- test Publish to test.pypi.org |
|
|
|
EOT |
|
} # ---------- end of function __usage ---------- |
|
|
|
while getopts ':h' opt |
|
do |
|
case "${opt}" in |
|
h ) __usage; exit 0 ;; |
|
\?) echo "Invalid option : $OPTARG" |
|
__usage |
|
exit 1 |
|
;; |
|
esac |
|
done |
|
shift $((OPTIND-1)) |
|
|
|
|
|
# Define publish type |
|
if [ "$#" -gt 0 ]; then |
|
PTYPE=$1 |
|
shift |
|
fi |
|
|
|
# Check publish type |
|
if [ "$(echo "$PTYPE" | grep -E '(pypi|test)')" = "" ]; then |
|
echo "Publish type \"$PTYPE\" is invalid..." |
|
exit 1 |
|
fi |
|
|
|
# Set the token |
|
_TOKEN=$test_token # Default |
|
_REPO="testpypi" |
|
if [ "$(echo "$PTYPE" | grep -E '(pypi)')" = "pypi" ]; then |
|
_TOKEN=$pypi_token |
|
_REPO="pypi" |
|
echo "Publishing to PYPI official..." |
|
fi |
|
|
|
# Upgrade pip packages |
|
python3 -m pip install pip --upgrade |
|
python3 -m pip install setuptools --upgrade |
|
python3 -m pip install wheel --upgrade |
|
python3 -m pip install twine --upgrade |
|
python3 -m pip install build --upgrade |
|
|
|
# build current version |
|
# note: mkae sure to update setup.py first |
|
python3 -m build |
|
|
|
# command: python3 -m twine upload --username $_USERNAME --password $_TOKEN --non-interactive --repository $_REPO dist/* |
|
python3 -m twine upload --verbose --username $_USERNAME --password $_TOKEN --non-interactive --repository $_REPO dist/* |
|
|
|
|
|
|