From: Hans-Christoph Steiner Date: Mon, 27 Nov 2017 14:23:02 +0000 (+0100) Subject: check git is on correct tag before making a release X-Git-Tag: 0.9.1~2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=fdroidserver.git;a=commitdiff_plain;h=875dfd0d60099a9cef7445301aa19d9d3fab55e8 check git is on correct tag before making a release --- diff --git a/setup.cfg b/setup.cfg index afaf13e2..76777df3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,8 @@ +# uploading here requires Python 3.5.3+ or setuptools 27+, +# use instead: twine upload dist/fdroidserver*.tar.gz* [aliases] -release = register compile_catalog sdist upload --sign +release = versioncheck register compile_catalog sdist upload --sign # All this below is for Babel config. Ideally we would only use # Babel, but it is still missing some key features that gettext gives diff --git a/setup.py b/setup.py index 5e7e9a34..2c0c8564 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +from setuptools import Command from setuptools import setup import os import re @@ -7,6 +8,26 @@ import shutil import sys +class VersionCheckCommand(Command): + """Make sure git tag and version match before uploading""" + user_options = [] + + def initialize_options(self): + """Abstract method that is required to be overwritten""" + + def finalize_options(self): + """Abstract method that is required to be overwritten""" + + def run(self): + version = self.distribution.get_version() + version_git = subprocess.check_output(['git', 'describe', '--tags', '--always']).rstrip().decode('utf-8') + if version != version_git: + print('ERROR: Release version mismatch! setup.py (%s) does not match git (%s)' + % (version, version_git)) + sys.exit(1) + print('Upload using: twine upload dist/fdroidserver*.tar.gz*') + + def get_data_files(): # workaround issue on OSX or --user installs, where sys.prefix is not an installable location if os.access(sys.prefix, os.W_OK | os.X_OK): @@ -56,6 +77,7 @@ setup(name='fdroidserver', scripts=['fdroid', 'fd-commit', 'makebuildserver'], data_files=get_data_files(), python_requires='>=3.4', + cmdclass={'versioncheck': VersionCheckCommand}, install_requires=[ 'clint', 'GitPython',