Poetry plugin to update __version__ in __init__ file and other files containing version strings
Project description
The poetry version command only updates version in pyproject.toml file. This plugin updates version in other files when poetry version <version> command is executed.
Getting Started
Prerequisites
poetry = ^1.2.0a2
Install
Install the plugin by poetry plugin command.
poetry self add poetry-bumpversion
Configure version replacements
Say you have __version__ variable set at your_package/__init__.py file
__version__ = "0.1.0" # It MUST match the version in pyproject.toml file
Add the following to your pyproject.toml file.
[tool.poetry_bumpversion.file."your_package/__init__.py"]
# Duplicate the line above to add more files
Now run poetry version patch --dry-run, if your output looks somewhat like below you are all set (dry-run does not update any file).
Bumping version from 0.5.0 to 0.5.1 poetry-bumpversion: processed file: your_package/__init__.py
If dry-run output looks fine you can run version update command without dry-run flag to check if version in both pyproject.toml and your_package/__init__.py file has been updated.
Advanced Usage
You can define search and replace terms to be more precise
[tool.poetry_bumpversion.file."your_package/__init__.py"]
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'
You can define replacements if you have same search/replace patterns across multiple files.
[[tool.poetry_bumpversion.replacements]]
files = ["your_package/__init__.py", "your_package/version.py"]
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'
[[tool.poetry_bumpversion.replacements]]
files = ["README.md"]
search = 'version: {current_version}'
replace = 'version: {new_version}'
Usage with Github Workflow
This plugin uses itself in it’s “Deploy to PyPI” workflow. When a release tag is created on GitHub, the workflow updates package version using the release tag name and deploys it to PyPI. You can copy the deploy workflow code to your repository to set it up.
License
This project is licensed under MIT License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file poetry_bumpversion-0.3.1.tar.gz
.
File metadata
- Download URL: poetry_bumpversion-0.3.1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.15.0-1040-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d8899213e39371c772b53f432d306e85e34b68f9ccdf97f0108ec58f1294ca7 |
|
MD5 | 68eb0c07ec995911bcd980d0e6044660 |
|
BLAKE2b-256 | 2c9a6cf5ee2d7d6deb7d7828bcc9369b9ae174f71a4ed9bc49b7a31b3297a4a1 |
File details
Details for the file poetry_bumpversion-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: poetry_bumpversion-0.3.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.15.0-1040-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 870ea053455d5c5eca7e96e8304d6473f0b8b8bf977f32818c27e4d6e9caa7bc |
|
MD5 | c1afc334a097f99d8e7febbbce13697c |
|
BLAKE2b-256 | cc260715e8fc3a683c79deedc55c480d59575c820ae7582a581cea8f6d01329c |