diff --git a/.circleci/config.yml b/.circleci/config.yml index db83532dd5..45f49b8e25 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -80,25 +80,29 @@ jobs: - run: name: PyPI publish command: | - if [ -n "$(git diff --name-only $CIRCLE_SHA1^..$CIRCLE_SHA1 | grep 'pyproject.toml')" ]; then - echo "pyproject.toml modified" - echo -e "[pypi]\nusername = __token__\npassword = $PYPI_API_TOKEN" > ~/.pypirc - python -m pip install --upgrade pip - pip install build - pip install wheel - pip install --upgrade twine setuptools - rm -rf build dist + echo "Install TOML package." + python -m pip install toml + VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])") + PACKAGE_NAME=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['name'])") + if ! pip show -v $PACKAGE_NAME | grep -q "Version: ${VERSION}"; then + echo "pyproject.toml modified" + echo -e "[pypi]\nusername = __token__\npassword = $PYPI_API_TOKEN" > ~/.pypirc + python -m pip install --upgrade pip + pip install build + pip install wheel + pip install --upgrade twine setuptools + rm -rf build dist - echo "Building package" - python -m build + echo "Building package" + python -m build - echo "Twine upload to dist" - echo "Contents of dist directory:" - ls dist/ - twine upload --verbose dist/* + echo "Twine upload to dist" + echo "Contents of dist directory:" + ls dist/ + twine upload --verbose dist/* else - echo "No changes to pyproject.toml. Skipping PyPI publish." - circleci step halt + echo "Version ${VERSION} of package is already published on PyPI. Skipping PyPI publish." + circleci step halt fi workflows: