Skip to main content

Python version bumper

Project description

Build Code Coverage Version License Python Version

A simple Python script for updating the version in Kubernetes Helm Chart.yaml, VERSION, and pyproject.toml/setup.py files.

  • Ensures version consistency across all files.

  • Enforces Semantic Versioning 2.0.0.

  • Supports an optional lowercase ‘v’ prefix (e.g., v1.5.4-beta2).

./docs/pybump-recording.gif

Installation

To install pybump, run:

pip install pybump

Usage

Bumping Versions

To bump the version:

pybump bump [-h] --file PATH_TO_CHART.YAML --level {major,minor,patch} [--quiet]

Setting Explicit Versions

To set an explicit version or automatically update release metadata:

pybump set --file PATH_TO_CHART.YAML --set-version X.Y.Z [--quiet]

The auto flag is primarily intended for CI/CD pipelines, such as pull request workflows:

pybump set --file PATH_TO_CHART.YAML --auto [--quiet]

When using –auto, pybump appends the Git commit hash as release metadata to the version.

  • Warning - The –auto flag can be risky, as it may detect a Git repository unintentionally. Ensure that the target file is part of the correct repository before running this command.

Retrieving the Current Version

To get the current version:

pybump get --file PATH_TO_CHART.YAML

Updating Helm Chart appVersion

To bump, get, or set the appVersion field in a Helm chart, use the --app-version flag:

pybump bump [-h] --file PATH_TO_CHART.YAML --level {major,minor,patch} [--quiet] [--app-version]

Examples

CI Usage example

A simple Jenkins CI pipeline (using the Kubernetes plugin) that utilizes the set --file setup.py --auto option:

String label = "test-bump-ci-runner"
podTemplate(
        label: label,
        containers: [
                containerTemplate(
                        name: 'pybump',
                        image: "arielev/pybump:1.10.2",
                        ttyEnabled: true,
                        command: 'sleep',
                        args: '1d'
                ),
                containerTemplate(
                        name: 'jnlp',
                        image: 'jenkins/inbound-agent:jdk11',
                        ttyEnabled: true
                )
        ]
) {
    node(label) {
        timeout(time: 10, unit: 'MINUTES') {
            ansiColor('xterm') {
                String version = ""
                container('jnlp') {
                    git credentialsId: "credentials_id_here", url: "https://github.com/arielevs/pybump"
                }
                container('pybump') {
                    version = sh(
                            script: "pybump set --file setup.py --auto",
                            returnStdout: true
                    ).trim()
                }
                println(version)
            }
        }
    }
}

Version Bumping Examples

Case: version: 0.0.1

pybump bump --file Chart.yaml --level patch

Result: Version updated to 0.0.2.

Case: version: 0.1.4-alpha+meta.data

pybump bump --file Chart.yaml --level minor

Result: Version updated to 0.2.0-alpha+meta.data.

Case: version: v0.0.3

pybump bump --file Chart.yaml --level major

Result: Version updated to v1.0.0.

Case: version: 0.0.1+some-metadata

pybump set --file Chart.yaml --set-version 1.4.0

Result: Version updated to 1.4.0+metadata-here.

Case: version: v7.0.2

pybump set --file setup.py --auto

Result: Version updated to v7.0.2-5a51e0e1d9894d3c5d4201619f10be242320cb59.

Case: appVersion: 2.3.2

pybump bump --file Chart.yaml --level patch --app-version

Result: appVersion updated to 2.3.3.

Case: version: 1.0.13

pybump get --file Chart.yaml

Result: Returns 1.0.13.

Case: version: 1.0.13+some-metadata

pybump get --file Chart.yaml --release

Result: Returns some.

Using a Container Image

To run pybump within a container:

docker run --rm --volume $(pwd):/tmp -t arielev/pybump set --file /tmp/setup.py --auto

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

pybump-1.14.1.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

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

pybump-1.14.1-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file pybump-1.14.1.tar.gz.

File metadata

  • Download URL: pybump-1.14.1.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for pybump-1.14.1.tar.gz
Algorithm Hash digest
SHA256 72b5e4499eba33475f57e08916087e2e35f19f155289f9938de699e80facfcf8
MD5 4962be7c24f337c241c8d1791946ce5d
BLAKE2b-256 42df1e07c80b143ad97b5f6f343d4a898837e86c59ac868b4dd19141bf4c0ce0

See more details on using hashes here.

File details

Details for the file pybump-1.14.1-py3-none-any.whl.

File metadata

  • Download URL: pybump-1.14.1-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for pybump-1.14.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8c25cba88e8d1458cbc0617d4d355c95cdb3e656b9058fbcb69f2b95599a404b
MD5 2bda4513b8b9319117f36b8912346bd6
BLAKE2b-256 5761d8d99819cad5b4043b15ebbd4d87a5ac1fe0aebb53b831cf36d6f634c789

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