#!/bin/sh -ex

PROJECT="mkautodoc"
VERSION=`cat ${PROJECT}/__init__.py | grep __version__ | sed "s/__version__ = //" | sed "s/'//g"`

if [ -d 'venv' ] ; then
    BIN_PATH="venv/bin/"
else
    BIN_PATH=""
fi

if ! command -v "${BIN_PATH}twine" &>/dev/null ; then
    echo "Unable to find the 'twine' command."
    echo "Install from PyPI, using '${BIN_PATH}pip install twine'."
    exit 1
fi

scripts/clean

${BIN_PATH}python setup.py sdist
${BIN_PATH}twine upload dist/*
# ${BIN_PATH}mkdocs gh-deploy

scripts/clean

echo "You probably want to also tag the version now:"
echo "git tag -a ${VERSION} -m 'version ${VERSION}'"
echo "git push --tags"
