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.8.2.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.8.2-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: poetry_versions_plugin-0.8.2.tar.gz
  • Upload date:
  • Size: 6.9 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.8.2.tar.gz
Algorithm Hash digest
SHA256 b34d169eef81ae7240632f34d2742513a53ed453e5f4d8868d037446ee49d6b6
MD5 c507a8d019ce5fa1c3e5ac8ce3b7b2c4
BLAKE2b-256 f089ad7f427273d023939bc39d5088e36f257055b747e22225c5bcdb90e210ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for poetry_versions_plugin-0.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 793c63ac76bf47feedca325ea7af7c4e82edb5494086b2235e96ebbe44489018
MD5 975aadb295d9bc324261d50a28931f76
BLAKE2b-256 3dffa59cb6aa131fefb2ec5aeea1f0f7614da47816af9b1f830e3bff41170211

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