Skip to main content

bump semver anywhere

PyPI version

This is a library intented to replace all semversion bumpers and finally be agnostic of the language / use case for your semantic versioning. This is achieved by providing the regex pattern to the place and filename of the string that contains the semantic version.

usage

  • install pip install bump_semver_anywhere
  • create a bump_semver_anywhere.toml in the root of your project (see config example) or run bump_semver_anywhere init
  • run bump_semver_anywhere bump -p patch
Hello there. Today I want to show you a library I have been working on. I was inspired by necessity of changing all the versions in every file: `pyproject.toml`, `__init__.py`, `docker-compose.yaml`, `package.json`, etc. I searched for packages that do this but either they are specific to the language (Python or Javascript) or I did not like the customization for it. At the end I decided to create `bump_semver_anywhere`. This is inspired in [bump2version](https://github.com/c4urself/bump2version/) but with a much simpler approach. It uses TOML for configuration.

> This is a library intended to replace all semantic version bumpers and finally be agnostic of the language. This is achieved by providing the regex pattern to the place and filename of the string that contains the version.

configuration example:
```toml
# bump_semver_anywhere.toml

[general]
current_version = "0.1.2"

[vcs]
commit = true
commit_msg = "release({part}): bump {current_version} -> {new_version}"

[files]

[files.python-module]
filename = "bump_semver_anywhere/__init__.py"
pattern = '__version__ ?= ?"(.*?)"'

[files.python-pyproject]
filename = "pyproject.toml"
pattern = 'version ?= ?"(.*?)"'

It can be run as CLI bump_semver_anywhere bump -p patch or triggered via a Github action by commenting /release patch

❯ python -m bump_semver_anywhere bump -p patch
[-] Loading config from bump_semver_anywhere.toml and bumping patch
[=] config loaded
[ ] files to update
 • bump_semver_anywhere/__init__.py: 0.1.1
 • pyproject.toml: 0.1.1
 • bump_semver_anywhere.toml: 0.1.1
[ ] VCS enabled with git
[-] bumping patch version
 • bump_semver_anywhere/__init__.py -> 0.1.2
 • pyproject.toml -> 0.1.2
 • bump_semver_anywhere.toml -> 0.1.2
[*] saving files to disk
[*] staging
[*] commiting: release(patch): bump 0.1.1 -> 0.1.2
black....................................................................Passed
isort....................................................................Passed
flake8...................................................................Passed
[main 5092515] release(patch): bump 0.1.1 -> 0.1.2
 3 files changed, 3 insertions(+), 3 deletions(-)
[+] bye bye

PS: If you have any suggestions for changing the name to a much simpler one I will be grateful. PS2: I accept PR and any feedback.

cli

❯ bump_semver_anywhere --help
Usage: python -m bump_semver_anywhere [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  bump  Bump your semantic version of any software using regex
  init  Initialize the config
❯ bump_semver_anywhere bump --help
Usage: python -m bump_semver_anywhere bump [OPTIONS]

  Bump your semantic version of any software using regex

Options:
  -c, --config FILE               the config file  [default:
                                  bump_semver_anywhere.toml]
  -p, --part [major|minor|patch|prerelease]
                                  the version part to bump  [required]
  -n, --dry-run                   do not modify files
  --help                          Show this message and exit.
❯ bump_semver_anywhere init --help
Usage: python -m bump_semver_anywhere init [OPTIONS]

  Initialize the config

Options:
  -o, --output PATH  the output config file path  [default:
                     bump_semver_anywhere.toml]
  --help             Show this message and exit.

config example

The following example will bump the version for docker and a python or javascript package.

# bump_semver_anywhere.toml

[general]
current_version = "0.1.0"

[vcs]
commit = true
commit_msg = "release({part}): bump {current_version} -> {new_version}"

[files]

[files.docker]
filename = "docker-compose.yaml"
pattern = 'image:.*?:(.*?)"'

[files.python-module]
filename = "__init__.py"
pattern = '__version__ ?= ?"(.*?)"'

[files.python-pyproject]
filename = "pyproject.toml"
pattern = 'version ?= ?"(.*?)"'

[files.javascript]
filename = "package.json"
pattern = '"version": ?"(.*?)"'

github action

See .github/workflows/bump_semver_anywhere.yaml to integrate the action to your repo.

The current behaviour is to comment /release <part> (e.g. /release patch) in a pull request. Per default it pushes the bump commit to the branch the PR points to. Therefore it should be commented after accepting the PR

Release files for bump-semver-anywhere 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bump-semver-anywhere 0.3.0
File Size Uploaded
bump_semver_anywhere-0.3.0.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bump-semver-anywhere 0.3.0
File Interpreter ABI Platform
bump_semver_anywhere-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.6 kB

Release files / bump_semver_anywhere-0.3.0.tar.gz

Download URL bump_semver_anywhere-0.3.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
99e55cc08219aaca2c4aa44a209c5d2c0728f82dbfdd4ae51e99f03b483f80bd
BLAKE2b-256 checksum
How to use checksums
4e5ad6f2c555d4c50e8fee2018ce6d0cd747e5e31f92dc762d8e892f021a1c57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.8.12 Linux/5.11.0-1020-azure

Release files / bump_semver_anywhere-0.3.0-py3-none-any.whl

Download URL bump_semver_anywhere-0.3.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cf2b12ec83d516afea6c8db0c403b112e8644806d40c848ca5045242667893fd
BLAKE2b-256 checksum
How to use checksums
d5cfbd7eaff25444b4f035fcf5e01b1bc5bfcda958cd7989ac2a65727a7d7599
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.8.12 Linux/5.11.0-1020-azure

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page