#!/bin/bash

[ "${RELEASE_BUILD}" != "TRUE" ] && exit 0

git config user.email "zeny-man@zeny.io"
git config user.name "zeny-man"

CI_RELEASE_VERSION=`date +"v%Y-%m-%d"`

cat > $HOME/.pypirc << EOF
[pypi]
username = ${PYPI_USERNAME}
password = ${PYPI_PASSWORD}
EOF
chmod 600 $HOME/.pypirc

git commit -a -m "Update: ${CI_RELEASE_VERSION}"
git push --all

rm -fr ./dist/*
python setup.py release
twine upload dist/* -r pypi
