#!/bin/bash
script_dir="$(realpath $(dirname ${0}))"
exact_tag=$(git describe --exact-match --tags HEAD -- 2>/dev/null)
tag_stat=$?
if git diff-index --quiet HEAD --; then
if [ $tag_stat = 0 ]; then
if ( echo $exact_tag | grep beta ); then
echo This is a "beta" release, not publishing...
exit 0
fi
cat <<EOF > ~/.pypirc
[pypi]
username = __token__
password = $(cat ~/.fidipypi)
EOF
twine upload "${script_dir}"/dist/*
else
echo This is not a tag! Exiting...
exit 0
fi
else
echo Local changes detected! Exiting...
exit 0
fi