Add utility and makefile target to increase version number mechanically. Update release checklist.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-10-29 12:55:24 -04:00
parent d9ee75cc47
commit 033d6751e0
3 changed files with 230 additions and 38 deletions

View File

@@ -158,6 +158,13 @@ generate-setup:
# Releases
increase-version:
@VERSION=`grep "__version__ =" mayan/__init__.py| cut -d\' -f 2|./increase_version.py - $(PART)`; \
BUILD=`echo $$VERSION|awk '{split($$VERSION,a,"."); printf("0x%02d%02d%02d\n", a[1],a[2], a[3])}'`; \
sed -i -e "s/__build__ = 0x[0-9]*/__build__ = $${BUILD}/g" mayan/__init__.py; \
sed -i -e "s/__version__ = '[0-9\.]*'/__version__ = '$${VERSION}'/g" mayan/__init__.py; \
echo $$VERSION > docker/version
make generate-setup
test-release: clean wheel
twine upload dist/* -r testpypi

View File

@@ -405,22 +405,22 @@ X.Y # Final release
Release checklist
=================
1. Check for missing migrations::
#. Check for missing migrations::
make check-missing-migrations
2. Synchronize translations::
#. Synchronize translations::
make translations-pull
3. Compile translations::
#. Compile translations::
make translations-compile
4. Write release notes.
5. Update changelog.
6. Scan the code with flake8 for simple style warnings.
7. Check README.rst format with::
#. Update changelog.
#. Write release notes.
#. Scan the code with flake8 for simple style warnings.
#. Check README.rst format with::
python setup.py check -r -s
@@ -428,49 +428,68 @@ or with::
make check-readme
8. Bump version in `mayan/__init__.py`.
9. Bump version in `docker/version`.
10. Update requirements version in `setup.py` using:
#. Bump version in ``mayan/__init__.py`` and ``docker/version``::
make increase-version PART=<major, minor or micro>
#. Update requirements version in ``setup.py`` using:
::
make generate-setup
11. Build source package and test:
#. Build source package and test:
::
make test-sdist-via-docker-ubuntu
12. Build wheel package and test:
#. Build wheel package and test:
::
make test-wheel-via-docker-ubuntu
13. Tag version:
#. Tag version:
::
git tag -a vX.Y.Z -m "Version X.Y.Z"
14. Switch to the `releases` branch:
#. Generate set ``setup.py`` again to update the build number::
make generate-setup
#. Commit the new ``setup.py`` file.
#. Release the version using one of the two following methods: GitLab CI or
manual
Release using GitLab CI
-----------------------
#. Switch to the ``releases/all`` branch and merge the latest changes:
::
git checkout releases
git checkout releases/all
git merge versions/next
15. Push tag upstream:
::
git push --tags
16. Push code to trigger builds:
#. Push code to trigger builds:
::
git push
17. Build and upload a test release:
#. Push tag upstream:
::
git push --tags
Manual release
--------------
#. Build and upload a test release:
::
make release-test-via-docker-ubuntu
18. Build and upload a final release:
#. Build and upload a final release:
::
make release-via-docker-ubuntu

166
increase_version.py Executable file
View File

@@ -0,0 +1,166 @@
#!/usr/bin/env python
from __future__ import print_function, unicode_literals
import doctest
import re
import sys
import mayan
VERSION_PART_MAJOR = 0
VERSION_PART_MINOR = 1
VERSION_PART_MICRO = 2
class Version(object):
"""
>>> Version('1')
Version: 1
>>> Version('1.0')
Version: 1.0
>>> Version('1.3.2')
Version: 1.3.2
>>> Version('1').increment_part(part=VERSION_PART_MAJOR)
Version: 2
>>> Version('1').increment_part(part=VERSION_PART_MINOR)
Version: 1.1
>>> Version('1').increment_part(part=VERSION_PART_MICRO)
Version: 1.0.1
>>> Version('1rc').increment_part(part=VERSION_PART_MAJOR)
Version: 2rc
>>> Version('1rc2').increment_part(part=VERSION_PART_MAJOR)
Version: 1rc3
>>> Version('1rc0').increment_part(part=VERSION_PART_MAJOR)
Version: 1rc1
>>> Version('1.rc0').increment_part(part=VERSION_PART_MINOR)
Version: 1.rc1
>>> Version('1.0.rc1').increment_part(part=VERSION_PART_MINOR)
Version: 1.1
>>> Version('1.0.rc1').increment_part(part=VERSION_PART_MICRO)
Version: 1.0.rc2
>>> Version('1rc').increment_part(part=VERSION_PART_MINOR)
Version: 1rc.1
>>> Version('1rc').increment_part(part=VERSION_PART_MINOR)
Version: 1rc.1
>>> Version('1rc').increment_part(part=VERSION_PART_MICRO)
Version: 1rc.0.1
>>> Version('1.rc1').increment_part(part=VERSION_PART_MINOR)
Version: 1.rc2
>>> Version('1.rc1').increment_part(part=VERSION_PART_MICRO)
Version: 1.rc1.1
>>> Version('1.1.rc1').increment_part(part=VERSION_PART_MICRO)
Version: 1.1.rc2
>>> Version('1.2.3').increment_major()
Version: 2
>>> Version('1.2.3').increment_minor()
Version: 1.3
>>> Version('1.2.3').increment_micro()
Version: 1.2.4
"""
def __init__(self, version_string):
self._version_string = version_string
self._version_parts = version_string.split('.')
def _get_version_part(self, index):
try:
return self._version_parts[index]
except IndexError:
return 0
def __repr__(self):
return 'Version: {}'.format(self.get_version_string())
def increment_major(self):
return self.increment_part(part=VERSION_PART_MAJOR)
def increment_minor(self):
return self.increment_part(part=VERSION_PART_MINOR)
def increment_micro(self):
return self.increment_part(part=VERSION_PART_MICRO)
def increment_part(self, part):
# Fill version parts if the requested part is lower than what is
# available
self._version_parts.extend(
['0'] * (part - len(self._version_parts) + 1)
)
try:
version_part = self._version_parts[part]
except IndexError:
part_numeric_post = ''
part_numeric_pre = ''
part_text = ''
else:
part_numeric_pre, part_text, part_numeric_post = re.findall(
'^(\d+)*([A-Za-z]+)*(\d+)*$', version_part
)[0]
if part_numeric_post:
part_numeric_post = int(part_numeric_post) + 1
else:
part_numeric_pre = int(part_numeric_pre) + 1
self._version_parts[part] = '{}{}{}'.format(
part_numeric_pre, part_text, part_numeric_post
)
# Discard version parts lower than what is being increased
self._version_parts = self._version_parts[0:part + 1]
self._version_string = '.'.join(self._version_parts)
return self
def get_version_string(self):
return self._version_string
@property
def major(self):
return self._get_version_part(VERSION_PART_MAJOR)
@property
def minor(self):
return self._get_version_part(VERSION_PART_MINOR)
@property
def micro(self):
return self._get_version_part(VERSION_PART_MICRO)
if __name__ == '__main__':
# Remove comment to run tests
# doctest.testmod()
# exit(0)
if len(sys.argv) == 1:
print(
'usage: <part to increase [major, minor, micro]>'
)
exit(0)
if len(sys.argv) < 3:
print('Insufficient arguments')
exit(1)
version_string = sys.argv[1]
if version_string == '-':
version_string = sys.stdin.read().replace('\n', '')
version = Version(version_string)
part = sys.argv[2].lower()
if part == 'major':
version.increment_major()
elif part == 'minor':
version.increment_minor()
elif part == 'micro':
version.increment_micro()
else:
print('Unknown part')
exit(1)
#sys.stdout.write(version.get_version_string())
print(version.get_version_string())