Skip to main content

A CLI tool for calendar-based version bumping

Project description

PyPI version fury.io Downloads Downloads Downloads

Support Python Versions

Static Badge Ruff Coverage Status Tests Status

CI/CD Pipeline:

Testing - Main Testing - Dev

SonarCloud:

Coverage Maintainability Rating Quality Gate Status Reliability Rating Vulnerabilities

BumpCalver CLI Documentation

Note

This project should be consider in beta as it could have bugs due to being only a few months old.

Overview

The BumpCalver CLI is a command-line interface for calendar-based version bumping. It automates the process of updating version strings in your project's files based on the current date and build count. Additionally, it can create Git tags and commit changes automatically. The CLI is highly configurable via a pyproject.toml file and supports various customization options to fit your project's needs.


Table of Contents


Installation

To install the BumpCalver CLI, you can add it to your project's dependencies. If it's packaged as a Python module, you might install it via:

pip install bumpcalver

Note: Replace the installation command with the actual method based on how the package is distributed.


Getting Started

  1. Configure Your Project: Create or update the pyproject.toml file in your project's root directory to include the [tool.bumpcalver] section with your desired settings.

  2. Run the CLI: Use the bumpcalver command with appropriate options to bump your project's version.

Example:

bumpcalver --build --git-tag --auto-commit

Configuration

The BumpCalver CLI relies on a pyproject.toml configuration file located at the root of your project. This file specifies how versioning should be handled, which files to update, and other settings.

As an alternative, you can use configuration file named bumpcalver.toml. The CLI will look for this file if pyproject.toml is not found.

Configuration Options

  • version_format (string): Format string for the version. Should include {current_date} and {build_count} placeholders.
  • date_format (string): Format string for the date. Supports various combinations of year, month, day, quarter, and week.
  • timezone (string): Timezone for date calculations (e.g., UTC, America/New_York).
  • file (list of tables): Specifies which files to update and how to find the version string.
    • path (string): Path to the file to be updated.
    • file_type (string): Type of the file (e.g., python, toml, yaml, json, xml, dockerfile, makefile, properties, env, setup.cfg).
    • variable (string, optional): The variable name that holds the version string in the file.
    • pattern (string, optional): A regex pattern to find the version string.
    • version_standard (string, optional): The versioning standard to follow (e.g., python for PEP 440).
  • git_tag (boolean): Whether to create a Git tag with the new version.
  • auto_commit (boolean): Whether to automatically commit changes when creating a Git tag.

Example Configuration

[tool.bumpcalver]
version_format = "{current_date}-{build_count:03}"
date_format = "%y.%m.%d"
timezone = "America/New_York"
git_tag = true
auto_commit = true

[[tool.bumpcalver.file]]
path = "pyproject.toml"
file_type = "toml"
variable = "project.version"
version_standard = "python"

[[tool.bumpcalver.file]]
path = "examples/makefile"
file_type = "makefile"
variable = "APP_VERSION"
version_standard = "default"

[[tool.bumpcalver.file]]
path = "examples/dockerfile"
file_type = "dockerfile"
variable = "arg.VERSION"
version_standard = "default"

[[tool.bumpcalver.file]]
path = "examples/dockerfile"
file_type = "dockerfile"
variable = "env.APP_VERSION"
version_standard = "default"

[[tool.bumpcalver.file]]
path = "examples/p.py"
file_type = "python"
variable = "__version__"
version_standard = "python"

[[tool.bumpcalver.file]]
path = "sonar-project.properties"
file_type = "properties"
variable = "sonar.projectVersion"
version_standard = "default"

[[tool.bumpcalver.file]]
path = ".env"
file_type = "env"
variable = "VERSION"
version_standard = "default"

[[tool.bumpcalver.file]]
path = "setup.cfg"
file_type = "setup.cfg"
variable = "metadata.version"
version_standard = "python"

Date Format Examples

The date_format option allows you to customize the date format used in version strings. Here are some examples of how to format dates:

  • %Y.%m.%d - Full year, month, and day (e.g., 2024.12.25)
  • %y.%m.%d - Year without century, month, and day (e.g., 24.12.25)
  • %y.Q%q - Year and quarter (e.g., 24.Q1)
  • %y.%m - Year and month (e.g., 24.12)
  • %y.%j - Year and day of the year (e.g., 24.001 for January 1st, 2024)
  • %Y.%j - Full year and day of the year (e.g., 2024.001 for January 1st, 2024)
  • %Y.%m - Full year and month (e.g., 2024.12)
  • %Y.Q%q - Full year and quarter (e.g., 2024.Q1)

Refer to the Python datetime documentation for more format codes.


Supported File Types

BumpCalver supports version management for the following file types:

Core File Types

  • python - Python files with version variables (e.g., __version__ = "1.0.0")
  • toml - TOML configuration files (e.g., pyproject.toml)
  • yaml - YAML configuration files
  • json - JSON configuration files (e.g., package.json)
  • xml - XML configuration files

Infrastructure Files

  • dockerfile - Docker files with ARG or ENV variables
  • makefile - Makefiles with version variables

Configuration Files

  • properties - Java-style properties files (e.g., sonar-project.properties)
    • Format: key=value
    • Example: sonar.projectVersion=2025.02.02
  • env - Environment variable files (e.g., .env)
    • Format: KEY=value or KEY="value"
    • Example: VERSION=2025.02.02
  • setup.cfg - Python setup configuration files
    • Supports both dot notation (metadata.version) and simple keys (version)
    • Example: version = 2025.02.02 in [metadata] section

Command-Line Usage

The CLI provides several options to customize the version bumping process.

Usage: bumpcalver [OPTIONS]

Options:
  --beta                      Use beta versioning.
  --rc                        Use rc versioning.
  --release                   Use release versioning.
  --custom TEXT               Add custom suffix to version.
  --build                     Use build count versioning.
  --timezone TEXT             Timezone for date calculations (default: value
                              from config or America/New_York).
  --git-tag / --no-git-tag    Create a Git tag with the new version.
  --auto-commit / --no-auto-commit
                              Automatically commit changes when creating a Git
                              tag.
  --undo                      Undo the last version bump operation.
  --undo-id TEXT              Undo a specific operation by ID.
  --list-history              List recent operations that can be undone.
  --help                      Show this message and exit.

Version Bump Options

  • --beta: Adds .beta suffix to the version.
  • --rc: Adds .rc suffix to the version.
  • --release: Adds .release suffix to the version.
  • --custom TEXT: Adds a custom suffix to the version.
  • --build: Increments the build count based on the current date.
  • --timezone: Overrides the timezone specified in the configuration.
  • --git-tag / --no-git-tag: Forces Git tagging on or off, overriding the configuration.
  • --auto-commit / --no-auto-commit: Forces auto-commit on or off, overriding the configuration.

Undo Options

BumpCalver includes powerful undo functionality to revert version changes:

  • --undo: Undo the most recent version bump operation.
  • --undo-id TEXT: Undo a specific operation by its unique ID.
  • --list-history: Show recent version bump operations that can be undone.

Note: Undo options cannot be combined with version bump options.


Examples

Basic Version Bump

To bump the version using the current date and build count:

bumpcalver --build

Beta Versioning

To create a beta version:

bumpcalver --build --beta

Specifying Timezone

To use a specific timezone:

bumpcalver --build --timezone Europe/London

Creating a Git Tag with Auto-Commit

To bump the version, commit changes, and create a Git tag:

bumpcalver --build --git-tag --auto-commit

Undo Operations

View recent version bump operations:

bumpcalver --list-history

Undo the last version bump:

bumpcalver --undo

Undo a specific operation by ID:

bumpcalver --undo-id 20251012_143015_123

Safety Net Workflow

Use undo functionality as a safety net during development:

# Make experimental version bump
bumpcalver --custom "experimental"

# Test your changes...

# If tests pass, make official version
bumpcalver --undo  # Undo experimental version
bumpcalver --build --git-tag --auto-commit  # Official version

# If tests fail, just undo
bumpcalver --undo  # Back to original state

For complete undo documentation, see Undo Docs.


Documentation

For comprehensive information about BumpCalver, check out our documentation:

For the full documentation site, visit: BumpCalver CLI Documentation


Error Handling

  • Unknown Timezone: If an invalid timezone is specified, the default timezone (America/New_York) is used, and a warning is printed.
  • File Not Found: If a specified file is not found during version update, an error message is printed.
  • Invalid Build Count: If the existing build count in a file is invalid, it resets to 1, and a warning is printed.
  • Git Errors: Errors during Git operations are caught, and an error message is displayed.
  • Malformed Configuration: If the pyproject.toml file is malformed, an error is printed, and the program exits.

Support

For issues or questions, please open an issue on the project's repository.


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

bumpcalver-2025.12.30.1.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

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

bumpcalver-2025.12.30.1-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file bumpcalver-2025.12.30.1.tar.gz.

File metadata

  • Download URL: bumpcalver-2025.12.30.1.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for bumpcalver-2025.12.30.1.tar.gz
Algorithm Hash digest
SHA256 473b3c62d51d13c6c8614acd8ccf07d4536ace6344a95c74472fb559cbb26545
MD5 48cc073cd632c4b13e41e8f8a5f890aa
BLAKE2b-256 abcd78e1f704143f93564e8529633ac0d5b2154b5542adcf4efe97e5374b23d0

See more details on using hashes here.

File details

Details for the file bumpcalver-2025.12.30.1-py3-none-any.whl.

File metadata

File hashes

Hashes for bumpcalver-2025.12.30.1-py3-none-any.whl
Algorithm Hash digest
SHA256 40eeb73d93c457f8372f37924485c03d2ba05e4b37dfc228243dcc061a3e4b12
MD5 4469a719a3d3c9480fd7d2abe1f943b6
BLAKE2b-256 bba790475799a672a6d35bc93684ad74d6b612428e022d30b8d837c2f796086c

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