Sign inSign up

wiseaidev/bump2version

By wiseaidev

โ€ขUpdated 22 days ago

bump2version is the world's fastest version bumper written entirely in 100% safe Rust.

Image
Integration & delivery
0

462

wiseaidev/bump2version repository overview

โ โฌ†๏ธ Bump2version

bump2version logo

Crates.io Docs.rs PyPI npm Docker GitHub Marketplace License: MIT

bump2version is the world's fastest version bumper written entirely in 100% safe Rust, with no_std support, native Python and Node.js bindings, and a cargo bump subcommand ๐Ÿ—ฟ.

bump2version banner

โ ๐Ÿš€ Installation

PlatformCommand
Rust binarycargo install bump2version --features rust-binary
Cargo subcommandcargo bump --help
Dockerdocker pull wiseaidev/bump2version
Debian/UbuntuDownload .deb from GitHub Releasesโ 
RHEL/FedoraDownload .rpm from GitHub Releasesโ 
WindowsDownload bump.exe from GitHub Releasesโ 
GitHub ActionSee action.ymlโ 
Pythonpip install bump-rs
Node.jsnpm install bump2version

Note

Installing via `cargo` installs both `bump` and `bump2version` binaries. The original `bump2version` binary is retained indefinitely for backward compatibility with existing tutorials, CI/CD pipelines, and automation scripts.

โ ๐Ÿค” What does this crate provide?

bump2version automates semantic version management for any project regardless of language. It:

  • Parses version strings using a fully configurable regex (default: semver major.minor.patch).
  • Bumps any named component (major, minor, patch, or custom cyclic stages like alpha โ†’ beta โ†’ rc โ†’ stable).
  • Rewrites version occurrences across multiple files, including multiline CHANGELOG patterns.
  • Commits and tags via 100% pure gix (gitoxide); zero subprocess calls.
  • Detects version strings across any language's manifest files (Rust, Python, JS, Go, Java, Ruby).
  • Watches for file changes and bumps automatically on save.
  • Bumps workspaces atomically across all Cargo workspace members.

โ ๐Ÿ’ป Command-line Interface

# Install
cargo install bump2version --features rust-binary

# Use directly
bump --bump patch          # 0.2.1 โ†’ 0.2.2
bump --bump minor          # 0.2.1 โ†’ 0.3.0
bump --bump major          # 0.2.1 โ†’ 1.0.0
bump --bump patch --dry-run  # preview only

# Use as cargo subcommand
cargo bump --bump patch
cargo bump --bump minor --dry-run

# Docker
docker run --rm -v $(pwd):/workspace wiseaidev/bump2version --bump patch --dry-run

# Multi-language auto-detect
bump --bump patch --detect
OptionDescription
--config-fileConfig file path (default: .bumpversion.toml)
--current-versionOverride current version
--bumpComponent: major, minor, patch, or any custom part
--parseParse regex override
--serializeSerialize format override
--dry-run / -nSimulate without writing files
--new-versionExplicit new version (skips bump calculation)
--commit / --tagGit commit + lightweight tag

โ ๐Ÿ”ญ Features

FeatureDefaultDescription
stdโœ…File I/O, git integration, regex stdlib cache
cliโŒStandalone bump binary via clap
watchโŒFile-system watcher (bump on file save)
detectโŒMulti-language manifest auto-detection
pythonโŒPython extension module via PyO3/maturin
nodeโŒNode.js native add-on via napi-rs

โ ๐Ÿฆ€ Rust

The Rust crate is available on crates.ioโ . For a complete API reference visit RUST.mdโ .

โ Quick Start
[dependencies]
bump2version = "0.2.1"
use bump2version::{config::BumpConfig, version::{parse_version, bump_version, serialize_version}};

fn main() {
    let cfg = BumpConfig::default();
    let v   = parse_version("1.2.3", &cfg).unwrap();
    let v2  = bump_version(&v, "patch", &cfg).unwrap();
    println!("{}", serialize_version(&v2, &cfg)); // 1.2.4
}
โ no_std Support

Core modules (config, version, files, error) compile in no_std + alloc:

bump2version = { version = "0.2.1", default-features = false }
Moduleno_std+allocstd
configโœ…โœ…
versionโœ…โœ…
filesโœ…โœ…
errorโœ…โœ…
gitโŒโœ…
CLIโŒโœ…
Python / Node.jsโŒโœ…

โ ๐Ÿ Python

pip install bump-rs
from bump_rs import bump_version, apply_file_change, BumpConfig

print(bump_version("1.2.3", "patch"))   # "1.2.4"
print(bump_version("1.2.3", "minor"))   # "1.3.0"

cfg = BumpConfig(parse=r"(?P<major>\d+)\.(?P<minor>\d+)", serialize="{major}.{minor}")
print(bump_version("2.0", "minor", config=cfg))  # "2.1"

For full docs see PYTHON.mdโ .

โ ๐ŸŸฉ Node.js

npm install bump2version
const { bumpVersion, applyFileChange } = require("bump2version");
console.log(bumpVersion("1.2.3", "patch")); // '1.2.4'

For full docs see NODE.mdโ .

โ โš™๏ธ Configuration File (.bumpversion.toml)

[bumpversion]
current_version = "1.0.0"
commit = true
tag = true

[bumpversion:file:Cargo.toml]
search = 'version = "{current_version}"'
replace = 'version = "{new_version}"'

[bumpversion:file:CHANGELOG.md]
search = """
## {current_version}
    Release notes line 1"""
replace = """
## {new_version}
    Release notes line 1"""
โ Pre-release Cycling
[bumpversion]
current_version = "1.0.0-alpha.1"
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)-(?P<stage>[a-z]+)\.(?P<devnum>\d+)
serialize =
    {major}.{minor}.{patch}-{stage}.{devnum}
    {major}.{minor}.{patch}

[bumpversion:part:stage]
optional_value = stable
first_value = alpha
values =
    alpha
    beta
    rc
    stable
โ Cargo Workspace Bumping
# Atomically bump all workspace member crates
bump --bump patch

The workspace module discovers all [workspace] members and bumps every Cargo.toml in one pass.

โ ๐Ÿ”ญ GitHub Action

The action is published as bump-rsโ  on the GitHub Marketplace.

- uses: wiseaidev/bump-rs@main
  with:
    release_type: patch   # 'major', 'minor', or 'patch' - omit to auto-detect from git tags
    commit: "true"
    tag: "true"
    dry-run: "false"
    working-directory: "."
    config-file: ".bumpversion.toml"
OutputDescription
new_versionThe new version string after bumping
old_versionThe previous version string before bumping
release_typeThe component that was bumped (major/minor/patch)

โ ๐Ÿ”’ Safety

This crate enforces #![forbid(unsafe_code)] at the crate root (except the Node.js FFI layer which requires unsafe for napi-rs interop). Every byte of the implementation: config parsing, regex matching, version bumping, git object creation, is written in safe Rust.

โ ๐Ÿ“Š Benchmarks

โ CLI vs CLI: bump vs bump-my-version (hyperfine)

Measured with hyperfine --runs 5 --warmup 2 -N on x86-64 Linux (target-cpu=native release build):

ScenarioToolMeanMinMax
patch bumpbump (Rust)5.6 ms2.6 ms10.5 ms
minor bumpbump (Rust)3.9 ms2.8 ms6.2 ms
major bumpbump (Rust)2.5 ms1.9 ms3.2 ms
any bumpbump-my-version (Python)482.3 ms473.8 ms488.0 ms

CLI speedup: ~90-200ร— faster depending on scenario (major bump is fastest: ~193ร—).

At the library function level (pure parse+bump+serialize, no process startup):

BenchmarkRust (bump2version)Python (bump-my-version)Speedup
parse + bump + serialize~13 ยตs~79 ยตs~6ร—
Config parse (minimal)~12 ยตs~4 800 ยตs~400ร—
File replace, 10K lines~14 ms--
Full pipeline (CLI cold start)2.4 ms482 ms~200ร—

Run the comparison yourself:

# Rust
hyperfine --runs 10 -N "bump --config-file .bumpversion.toml --bump patch --dry-run"

# Python (if installed)
hyperfine --runs 10 "bump-my-version bump patch --dry-run"

# Full comparative suite
chmod +x benchmarks/hyperfine/run_comparison.sh
./benchmarks/hyperfine/run_comparison.sh
โ Internal Benchmarks (cargo bench)

Run with cargo bench. Results on x86-64 Linux after optimization (LTO=fat, opt-level=3, target-cpu=native):

BenchmarkTime
config_parse/minimal~12 ยตs
config_parse/full_with_parts~18 ยตs
version_parse/1.0.0~430 ns
version_bump/patch~13 ยตs
version_bump/minor~14 ยตs
version_bump/major~6 ยตs
prerelease_bump/stage~15 ยตs
file_replace/100 lines~240 ยตs
file_replace/1 000 lines~1.3 ms
file_replace/10 000 lines~14 ms
file_replace/100 000 lines~140 ms
worst_case/10 000 lines~14 ms
multiline_replace/100x~85 ยตs

โ ๐Ÿ“š Further Reading

โ ๐Ÿ“„ License

Licensed under the MIT Licenseโ .

Tag summary

Content type

Image

Digest

sha256:8d835c50aโ€ฆ

Size

5.5 MB

Last updated

22 days ago

docker pull wiseaidev/bump2version