check git is on correct tag before making a release

This commit is contained in:
Hans-Christoph Steiner 2017-11-27 15:23:02 +01:00
parent ff5717b37e
commit 875dfd0d60
2 changed files with 25 additions and 1 deletions

View File

@ -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

View File

@ -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',