diff --git a/.circleci/config.yml b/.circleci/config.yml index 70d871f9..def4ffc7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -47,6 +47,9 @@ jobs: steps: - checkout: path: /home/mythril + - run: + name: Verify Git tag vs. version + command: cd /home/mythril && python3 setup.py verify - run: name: Build command: cd /home/mythril && python3 setup.py sdist diff --git a/README_DEV.md b/README_DEV.md index 9c4ffa50..c61aa9dd 100644 --- a/README_DEV.md +++ b/README_DEV.md @@ -1,6 +1,16 @@ For Developers =============== +## Deployment to PyPI +- Update `VERSION` constant on top of `setup.py` file to `vX.Y.Z`, where `X`, + `Y`, `Z` are some integers specifying the new version of the package; +- Create Git tag with the same version name `vX.Y.Z`; +- Push the tag to `Mythril` repo, CircleCI will take care about the rest + (testing, and deployment to PyPI if tests are successful). + +In case of mismatch between Git tag and `VERSION` in `CircleCI` deployment will +be failed. + ## Running tests ### python version diff --git a/setup.py b/setup.py index 66d27ea7..d040155e 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,21 @@ from setuptools import setup, find_packages import os +# Package version (vX.Y.Z). It must match git tag being used for CircleCI +# deployment; otherwise the build will failed. +VERSION = "v0.16.7" + +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') + + if (tag != VERSION): + info = "Git tag: {0} does not match the version of this app: {1}".format(tag, VERSION) + sys.exit(info) + long_description = ''' Mythril is a security analysis tool for Ethereum smart contracts. It uses concolic analysis to detect various types of issues. Use it to @@ -254,7 +269,7 @@ Credit setup( name='mythril', - version=os.getenv('CIRCLE_TAG', 'v0.15.8')[1:], + version=VERSION[1:], description='Security analysis tool for Ethereum smart contracts', long_description=long_description, @@ -315,5 +330,9 @@ setup( include_package_data=True, - scripts=['myth'] + scripts=['myth'], + + cmdclass = { + 'verify': VerifyVersionCommand, + } )