Skip to main content

Poetry plugin that automates version management and records Git information for Python projects.

Project description

Poetry Versions Plugin

License

Overview

The Poetry Versions Plugin is a powerful extension for the Poetry dependency manager, designed to automate version management and record Git information for Python projects. This plugin simplifies the process of bumping version numbers and integrates seamlessly with Git to ensure that all changes are tracked effectively.

Features

  • Automated Version Management: Easily bump major, minor, or patch versions using the poetry version command.
  • Git Integration: Automatically records Git branch, commit, and status information within your project.
  • Customizable Workflow: Configure commit message formats, allow/disallow dirty repository states, and specify which files to update.
  • Release Process Automation: Provides a script to handle releases using git flow, ensuring a streamlined and consistent release process.

Installation

To install the Poetry Versions Plugin, add it to your Poetry project:

poetry add poetry-versions-plugin

Poetry will automatically recognize the plugin without needing additional configuration in your pyproject.toml.

Configuration

Configure the plugin in your pyproject.toml file under the [tool.versions.settings] section:

[tool.versions.settings]
allow_dirty = false
commit = true
commit_on = ["major", "minor", "patch"]
commit_message = "Bump version: {current_version} → {new_version}"
filename = [
    "poetry_versions_plugin/versions.py",
]

Main Configuration Options

allow_dirty: (default: false) If set to true, allows the version bumping even if the working directory has uncommitted changes. commit: (default: true) Automatically commit changes to the local git repository after a version bump. commit_on: Specifies which version types (major, minor, patch) trigger an automatic commit. commit_message: Format of the commit message for version bumps. filename: List of additional files to update with the new version information.

Usage

Bumping Versions

To bump the version of your project, use the poetry version command with the desired version type:

poetry version [major|minor|patch]

This command updates the version in your pyproject.toml, updates additional specified files, and commits changes if configured.

Release Process

The scripts.release:main script automates the release process using git flow. To execute a release:

poetry run release [major|minor|patch]

This script performs the following steps:

  1. Checks if you're on the develop branch.
  2. Verifies there are no uncommitted changes.
  3. Bumps the version number.
  4. Starts and finishes a git flow release.
  5. Publishes the package.

Customizing the Release Process with a Makefile

You can also customize the release process using a Makefile. Here is an example:

bump = patch
next-version = $(shell poetry version $(bump) -s --dry-run)
release:
	@echo "Creating a new release..."
	git flow release start $(next-version)
	poetry version $(bump)
	git flow release finish -m "publish"
	git push --all
	git push --tags

This Makefile example automates the version bumping and release process by leveraging git flow and Poetry commands.

Notes

The release script requires git flow to be installed and initialized in your repository. Ensure your repository is clean and on the correct branch before starting a release.

Testing

This project uses pytest for unit testing. To run tests:

poetry run pytest

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Contribution

We welcome contributions to the Poetry Versions Plugin! If you have suggestions, bug reports, or pull requests, please visit our GitHub repository.

Acknowledgments

Special thanks to the open-source community for their continuous support and contributions. Your feedback and contributions are what make projects like this possible!

Feel free to reach out via email for any additional questions or support.

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_versions_plugin-0.10.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

poetry_versions_plugin-0.10.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file poetry_versions_plugin-0.10.0.tar.gz.

File metadata

  • Download URL: poetry_versions_plugin-0.10.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.1 Darwin/24.3.0

File hashes

Hashes for poetry_versions_plugin-0.10.0.tar.gz
Algorithm Hash digest
SHA256 28d68a414675aac88830dc10a549c50b00ca8ed1f58be1d0a35dd0086084b437
MD5 2dae13b8d909042197aa304f900423ea
BLAKE2b-256 5a7a1db8b352bec651e8e2c9ce50191a9b7122e37f2e1be560f29bd6efc1da5d

See more details on using hashes here.

File details

Details for the file poetry_versions_plugin-0.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for poetry_versions_plugin-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5670dee62ddf7190b16a8829f8d148b342edf2925a323e8f6c5e2a9892bc94b2
MD5 9adea8cec19f7112df7820bfebd33f9f
BLAKE2b-256 5de8ff1491d777491354a714011ee6a924c1ebf871d0ee63a9cb43a1dc7f1b6f

See more details on using hashes here.

Supported by

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