bump-py-version
This is a simple and opinionated python tool to bump the of a python package.
-
The script will check for any changes in the current
gitrepository and abort if there are any. -
If there are no changes, it will check for a
versionfield inpyproject.toml. If theproject.versionexist it is altered to the specified version. Other options are specified below. -
The script commits and pushes the changes.
-
Then a new tag is created using the new
versionspecified to the script. -
Finally the script pushes the new tag to the remote repository.
Installation
Install latest version:
uv tool install git+https://github.com/diversen/bump-py-version@v2.1.0
Configuration
You may also bump the python version __version__ in e.g. __init__.py file (or similar) using a pyproject.toml setting like the following:
[tool.bump_version]
version_file = "bump_py_version/__init__.py"
You may configure the script to alter text files (e.g. README.md) by setting the section tool.bump_version.replace_patterns in the pyproject.toml file. Example:
[tool.bump_version.replace_patterns.pipx]
file = "README.md"
search = "<!-- LATEST-VERSION-UV -->"
replace = "\tuv tool install git+https://github.com/diversen/bump-py-version@{version}\n"
The above will cause the line below the search string to be replaced with the replace string. Then it is easy to show the latest version of the package in a README.md file.
Updating uv.lock
To update uv.lock as part of each version bump, enable:
[tool.bump_version]
uv_lock = true
This runs uv lock after updating the version files and before staging changes,
so the lockfile is included in the release commit and tag. It does not request
dependency upgrades. If the lockfile does not exist, uv lock creates it.
uv must be installed and available on PATH. The command checks these
prerequisites before modifying files and rejects an ignored uv.lock, explaining
that it must be removed from .gitignore or the applicable Git ignore rules.
An existing, untracked lockfile must be committed before bumping, just like any
other non-ignored untracked file.
If uv lock fails, the command stops before committing, pushing, or tagging;
local edits remain available for inspection. The setting defaults to false,
which preserves the existing behavior without running uv.
Usage example
Example:
bump-py-version v1.2.3
License
MIT © Dennis Iversen
Metadata
Release files for bump-py-version 2.1.0
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_py_version-2.1.0.tar.gz | 6.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bump_py_version-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.5 kB
Release files / bump_py_version-2.1.0.tar.gz
| Download URL | bump_py_version-2.1.0.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39ef5e6382a82433c2ce4112c4090d519e87c57e17b11e0b907a09eec59fdcd6
|
|
BLAKE2b-256 checksum How to use checksums |
0b96ad534033809fa2bd572a3acbab2d3f07325eaa461183d8cc878fda75ec6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / bump_py_version-2.1.0-py3-none-any.whl
| Download URL | bump_py_version-2.1.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
91513d4824b350762c7b9fa7144164b1e5bd5e9067ff01c56500d02de4fcf49a
|
|
BLAKE2b-256 checksum How to use checksums |
c2085bc7ec705057d63049d5d586031173a94d21608ce5e79669d2f9d7d89051
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|