Updates the release numbers for a projects
This script uses the release.ini file placed at the root of the project, and replaces the version or release number in various files.
$ cd <project_root>
$ ls -al
...
release.ini
...
$ bump_release <major>.<minor>.<release>
Installation
On linux, the best place to install it is for the user:
$ pip install --user bump-release
Assume to have ~/.local/bin in the $PATH.
Version numbers that can be updated
- main project version
- node package.json
- sonar properties
- sphinx docs
- ansible variables in a vars file
- setup.py
release.ini
The .ini file provides path, patterns and templates to update files.
If a section is not present, no action if performed for this section.
The application provides some "standard" patterns and templates (aka. the ones I use in my projects). If you provide some patterns and templates, you have to enclose them with double-quotes. Due to configparser limitations, all strings are parsed as raw strings.
The application removes those double-quotes through a :
pattern = config["<section>"].get("pattern") or DEFAULT_PATTERN
pattern = pattern.strip('"')
Exemple ini file:
[DEFAULT]
current_release = 0.1.0 # Current version of the projects, will be updated by the script
[main_project]
path = <project>/settings/base.py
# Optional pattern, default is...
pattern = "^__version__\s*=\s*VERSION\s*=\s*['\"][.\d\w]+['\"]$"
# Optional template, default is...
template = "__version__ = VERSION = '{major}.{minor}.{release}'"
[node_module]
path = <project>/assets/package.json
# Optional key, default is...
key = "version"
[sonar]
path = ./sonar-project.properties
# Optional pattern, default is...
pattern = "^sonar.projectVersion=([.\d]+)$"
# Optional template, default is...
template = "sonar.projectVersion={major}.{minor}"
[docs]
path = <project>/../docs/source/conf.py
# Optional pattern, default is...
version_pattern = "^version\s+=\s+[\"']([.\d]+)[\"']$"
# Optional template, default is...
version_format = "version = '{major}.{minor}'"
# Optional pattern, default is...
release_pattern = "^release\s+=\s+[\"']([.\d]+)[\"']$"
# Optional template, default is...
release_format = "release = '{major}.{minor}.{release}'"
[ansible]
path = <project>/../ansible/prod/vars/vars.yml"
# Optional key - The script searches for the "git" root key, and then for "version" sub-key
key = "git.version"
[setup]
path = <project>/setup.py
# Optional pattern, default is...
pattern = "^\s*version=['\"]([.\d]+)['\"],$"
# Optional template, default is...
template = " version='{major}.{minor}.{release}',"
Usage
$ cd <project_root>
$ cat release.ini
[DEFAULT}
current_release = 0.0.1
[main_project]
path = "foo/__init__.py"
[sonar]
path = "sonar-project.properties"
...
$ cat foo/__init__.py
...
__version__ = VERSION = "0.0.1"
...
$ bump_release 0.0.2
...
$ cat release.ini
[DEFAULT}
current_release = 0.0.2
...
$ cat foo/__init__.py
...
__version__ = VERSION = "0.0.2"
...
Metadata
Release files for bump-release 0.9.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bump_release-0.9.6.tar.gz | 9.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bump_release-0.9.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.4 kB
Release files / bump_release-0.9.6.tar.gz
| Download URL | bump_release-0.9.6.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b49a2918710edc533cbdfd8995e7e552781c0d232520f7959732b6a5120ff006
|
|
BLAKE2b-256 checksum How to use checksums |
ce0e0eb35c9dc9c5621a1e6b089a878f8b564bed30982704d4581a3284d8bada
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.10
|
Release files / bump_release-0.9.6-py3-none-any.whl
| Download URL | bump_release-0.9.6-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce6397f66f36033768032b5f733fef3d451f12c48ca0ae2b43b3fa70b801789e
|
|
BLAKE2b-256 checksum How to use checksums |
901d27678a9c8704eb5a8f5c356895e944c7243fcca20db188ea1daac4b9ef67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.10
|