Setup bumpversion

- Create `use_bumpversion` cookiecutter option.
- Require `bumpversion==0.5.3` locally.
- Refactor version resolution in `./docs/conf.py`: Now, there's a single 'source of truth', the `release` variable representing 'the full version, including alpha/beta/rc tags', allowing the `version` to be derived dynamically from itself.
- Provide bumpversion config file pinpointing project version in `./package.json` (the `version` attribute), `./{{cookiecutter.project_slug}}/__init__.py` (the `__version__` variable), and ./docs/conf.py (the `release` variable).
N.B. The whole point of refactoring `./docs/conf.py` was indeed to faciilitate seamless version bumping.
This commit is contained in:
Nikita P. Shupeyko 2017-03-01 15:26:43 +03:00
parent f3ea2570ab
commit e77564ca1f
4 changed files with 29 additions and 3 deletions

View File

@ -6,6 +6,7 @@
"description": "A short description of the project.", "description": "A short description of the project.",
"domain_name": "example.com", "domain_name": "example.com",
"version": "0.1.0", "version": "0.1.0",
"use_bumpversion": "y",
"timezone": "UTC", "timezone": "UTC",
"use_whitenoise": "y", "use_whitenoise": "y",
"use_celery": "n", "use_celery": "n",

View File

@ -0,0 +1,22 @@
[bumpversion]
current_version = {{ cookiecutter.version }}
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<pre>\d+)\.(?P<prenum>\d+))?
serialize =
{major}.{minor}.{patch}-{pre}.{prenum}
{major}.{minor}.{patch}
commit = True
tag = True
tag_name = {new_version}
[bumpversion:file:./package.json]
search = "version": "{current_version}"
replace = "version": "{new_version}"
[bumpversion:file:./{{cookiecutter.project_slug}}/__init__.py]
search = __version__ = '{current_version}'
replace = __version__ = '{new_version}'
[bumpversion:file:./docs/conf.py]
search = release = '{current_version}'
replace = release = '{new_version}'

View File

@ -50,10 +50,10 @@ copyright = """{% now 'utc', '%Y' %}, {{ cookiecutter.author_name }}"""
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
# built documents. # built documents.
# #
# The short X.Y version.
version = '0.1'
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = '0.1' release = '{{ cookiecutter.version }}'
# The short X.Y version.
version = '.'.join(release.split('.')[:2])
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.

View File

@ -17,3 +17,6 @@ ipdb==0.10.2
pytest-django==3.1.2 pytest-django==3.1.2
pytest-sugar==0.8.0 pytest-sugar==0.8.0
{% if cookiecutter.use_bumpversion == 'y' -%}
bumpversion==0.5.3
{%- endif %}