diff --git a/.circleci/config.yml b/.circleci/config.yml index 5745d697a5..0256f6e92a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -101,12 +101,12 @@ jobs: name: init .pypirc command: | echo -e "[pypi]" >> ~/.pypirc - echo -e "username = $PYPI_USERNAME" >> ~/.pypirc - echo -e "password = $PYPI_PASSWORD" >> ~/.pypirc + echo -e "username = __token__" >> ~/.pypirc + echo -e "password = $PIP_TOKEN" >> ~/.pypirc - run: name: create packages command: | - python setup.py sdist + python setup.py sdist bdist_wheel - run: name: upload to pypi command: | @@ -132,10 +132,8 @@ workflows: requires: - "v3.8" - deploy: - requires: - - "proglearn" filters: tags: - only: /[0-9]+(\.[0-9]+)*/ + only: /v[0-9]+(\.[0-9]+)*/ branches: ignore: /.*/ diff --git a/setup.py b/setup.py index 1fcd9a6db5..b7175af5b5 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,7 @@ -from setuptools import setup, find_packages import os +import sys +from setuptools import setup, find_packages +from setuptools.command.install import install # Find mgc version. PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) @@ -13,6 +15,23 @@ with open("requirements.txt", mode="r", encoding="utf8") as f: REQUIREMENTS = f.read() + +class VerifyVersionCommand(install): + """Custom command to verify that the git tag matches our version""" + + description = "verify that the git tag matches our version" + + def run(self): + tag = os.getenv("CIRCLE_TAG") + version = "v{}".format(VERSION) + + if tag != version: + info = "Git tag: {0} does not match the version of this app: {1}".format( + tag, version + ) + sys.exit(info) + + setup( name="proglearn", version=VERSION, @@ -37,4 +56,7 @@ install_requires=REQUIREMENTS, packages=find_packages(exclude=["tests", "tests.*", "tests/*"]), include_package_data=True, + cmdclass={ + "verify": VerifyVersionCommand, + }, )