https://github.com/diversen/bump-py-version
https://github.com/diversen/bump-py-version
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/diversen/bump-py-version
- Owner: diversen
- License: mit
- Created: 2024-01-03T11:43:12.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-06-06T21:48:25.000Z (about 1 year ago)
- Last Synced: 2025-06-06T22:30:05.456Z (about 1 year ago)
- Language: Python
- Size: 31.3 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bump-py-version
This is a simple and opinionated script to bump the version of a python package.
1. The script will check for any changes in the git repository and abort if there are any.
2. If there are no changes, it will alter files where a `version` is set, e.g. `pyproject.toml` or `__init__.py`. (Which files to alter are specified in the `pyproject.toml` file according to the `tool.bump_version` section.)
3. The script commits and pushes the changes.
4. Then a new tag is created using the `version` tag specified.
5. Finally the script pushes the tag to the remote repository.
## Installation
pipx install git+https://github.com/diversen/bump-py-version@v2.0.3
## Configuration
It may bump the version in a `__init__.py` file (or similar) using a pyproject settings like the following:
```toml
[tool.bump_version]
version_file = "bump_py_version/__init__.py"
```
**Note** about `setup.py`. `setup.py` should import the version from the `__init__.py` file. Example:
```python
from bump_py_version import __version__
```
If you have a pyproject file with a `project.version` or a `tool.poetry.version` section then the script will bump these versions too.
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:
```toml
[tool.bump_version.replace_patterns.pip]
file = "README.md"
search = ""
replace = "\tpip install git+https://github.com/diversen/bump-py-version@{version}\n"
[tool.bump_version.replace_patterns.pipx]
file = "README.md"
search = ""
replace = "\tpipx 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.
## Usage example
Example:
```bash
bump-py-version v0.0.1
```