Package: bump-release
Updates the release numbers for a projectsThis 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>InstallationSimple install (without pyproject.tml support)On linux, the best place to install it is for the user:$pipinstall--userbump-releaseAssume to have~/.local/binin the$PATH.You can use pipx too for the same purpose:$pipxinstallbump-releaseInstall with pyproject.tml supportFor pyproject.toml, you can use thepipxcommand:$pipinstall--userbump-release[toml]or with pipx:$pipxinstallbump-release[toml]This will install thebump-releasepackage and the toml dependencies:tomlitomli-wThese libs are the one used bysetuptoolsfor pyproject.toml file parsing / updating.Version numbers that can be updatedmain project versionnode package.jsonsonar propertiessphinx docsansible variables in a vars filesetup.pysetup.cfgpyproject.tomlrelease.iniThe .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 toconfigparserlimitations, all strings are parsed as raw strings.The application removes those double-quotes through a :pattern=config["<section>"].get("pattern")orDEFAULT_PATTERNpattern=pattern.strip('"')Example ini file:[DEFAULT]; Current version of the projects, will be updated by the scriptcurrent_release=0.1.0[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\w]+)$"; 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\w]+)[\"']$"; Optional template, default is...version_format="version = '{major}.{minor}'"; Optional pattern, default is...release_pattern="^release\s+=\s+[\"']([.\d\w]+)[\"']$"; 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-keykey="git.version"[setup]path=<project>/setup.py; Optional pattern, default is...pattern="^\s*version=['\"]([.\d\w]+)['\"],$"; Optional template, default is...template="    version='{major}.{minor}.{release}',"[setup_cfg]path=<project>/setup.cfg; Optional pattern, default is...pattern="^version = ([.\d\w]+)$"; Optional template, default is...template="version = {major}.{minor}.{release}"[pyproject]path=<project>/pyproject.toml; Optional key, default is...key="project.version"Usage$cd<project_root>
$catrelease.ini[DEFAULT]current_release=0.0.1[main_project]path="foo/__init__.py"[sonar]path="sonar-project.properties"...

$catfoo/__init__.py
...__version__=VERSION="0.0.1"...
$bump_release0.0.2
...
$catrelease.ini[DEFAULT]current_release=0.0.2
...
$catfoo/__init__.py
...__version__=VERSION="0.0.2"...