chiark / gitweb /
check git is on correct tag before making a release
authorHans-Christoph Steiner <hans@eds.org>
Mon, 27 Nov 2017 14:23:02 +0000 (15:23 +0100)
committerHans-Christoph Steiner <hans@eds.org>
Mon, 27 Nov 2017 15:57:30 +0000 (16:57 +0100)
setup.cfg
setup.py

index afaf13e21977e6e378afd59ed27c76c2c2c3df4d..76777df3d13a39b3de9b9605460de2f000a81df4 100644 (file)
--- 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
index 5e7e9a34c11cf2ae712445ae79a43f9467b1672e..2c0c85642e9655d22c89377f4c91148ffd0d6053 100755 (executable)
--- 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',