Skip to main content

Poetry plugin to update __version__ in __init__ file and other files containing version strings

Project description

Logo

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.

Build Status Coverage Status Python Versions PyPI version Licence

Getting Started

Prerequisites

  • python = ^3.9

  • poetry = ^1.2.0

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 can be used to bump version automatically during publishing to PyPI using a GitHub workflow. When a release tag is created the workflow will use that tag name e.g 2.0.1 to update versions in every files, build the package and publish to PyPI. This is how this plugin is deployed to PyPI.

To get started you can copy the deploy workflow code from this repo to your repo and 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

poetry_bumpversion-0.3.3.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

poetry_bumpversion-0.3.3-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file poetry_bumpversion-0.3.3.tar.gz.

File metadata

  • Download URL: poetry_bumpversion-0.3.3.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for poetry_bumpversion-0.3.3.tar.gz
Algorithm Hash digest
SHA256 1489cc8935bc1fd8cede3cfc46c928a51dd9b5fb956e266e0e1d25fa5b694780
MD5 f7ee417ecfb39b4e563d7deaafde4596
BLAKE2b-256 feb10db43d82297871a643f60034933a7823ced29e795daee2669b8023654a22

See more details on using hashes here.

Provenance

The following attestation bundles were made for poetry_bumpversion-0.3.3.tar.gz:

Publisher: deploy.yml on monim67/poetry-bumpversion

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file poetry_bumpversion-0.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for poetry_bumpversion-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2d286475e3d2ddb14f7cf52bd73bc6a23d5eff5fb141770be1bf044f48fe624b
MD5 5b6fcdff150e73bdc54278d3c4217b0d
BLAKE2b-256 507ad4e811837e3407f445749b904d964113ae10abbcf0642e217f63c9575e42

See more details on using hashes here.

Provenance

The following attestation bundles were made for poetry_bumpversion-0.3.3-py3-none-any.whl:

Publisher: deploy.yml on monim67/poetry-bumpversion

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page