63 lines
1.6 KiB
Bash
63 lines
1.6 KiB
Bash
|
#!/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>
|
||
|
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
|
||
|
|
||
|
# command: python3 -m twine upload --username $_USERNAME --password $_TOKEN --non-interactive --repository $_REPO dist/*
|
||
|
python3 -m twine upload --username $_USERNAME --password $_TOKEN --non-interactive --repository $_REPO dist/*
|
||
|
|
||
|
|