#!/usr/bin/env bash

set -e

git clean -fxd .
_version=$(git describe --exact-match --tags HEAD || echo $(poetry version -s).dev$(date +%Y%m%d))
VERSION=${_version#'v'} # remove prefixed 'v' if any
cp pyproject.toml /tmp/pyproject.toml.1
poetry version ${VERSION}
poetry build
python3 -m pip install twine --upgrade
twine upload dist/*.whl -u __token__ -p $BITIA_PYPI_TOKEN
mv /tmp/pyproject.toml.1 pyproject.toml