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.9.0.tar.gz (6.9 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.9.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for poetry_versions_plugin-0.9.0.tar.gz
Algorithm Hash digest
SHA256 8214c80205450789c6960292d5ec95dafea33a82e57f591a2a29e7add0857340
MD5 068a86cc311ffc48a86cefdabc7b36fd
BLAKE2b-256 167d731212cc569882cf8577700157a7ec46d79ee7293489038844e4b1405f7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for poetry_versions_plugin-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6ba99182ee63c377cb404de894795cda40441d48b9386ca22ed729ee79fe2b2
MD5 610ef9561db5c3bdba30d36b9001c8a2
BLAKE2b-256 b01a63b512462b35004d53b633890002a03584bb43c0dbfee4ee4754fff3eb36

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