| Crates.io | calver |
| lib.rs | calver |
| version | 1.0.0 |
| created_at | 2025-10-10 18:35:05.212614+00 |
| updated_at | 2025-10-10 18:35:05.212614+00 |
| description | Calver: A lightweight command-line tool for effortless Calendar Versioning increments. |
| homepage | |
| repository | https://gitlab.com/op_so/projects/calver |
| max_upload_size | |
| id | 1877319 |
| size | 98,793 |
A lightweight command-line tool for effortless Calendar Versioning increments.
CalVer is a simple yet powerful tool that generates calendar-based version numbers. It automatically creates version identifiers using the current date and manages patch increments intelligently, making it perfect for automated builds, daily releases, and development snapshots.
✨ Key Features
Binary file installation on Linux via the GitLab package registry of the project:
Docker (coming soon)
# From Dockerhub
docker run -it --rm jfxs/calver calver help
# From Quay.io
docker run -it --rm quay.io/ifxs/calver calver help
cargo install calver
# Basic usage with defaults
$ calver bump
2025.09.15-0
# Custom format and separator
$ calver bump --format "%Y%m%d" --separator "_v"
20250915_v0
# Explicit patch number
$ calver bump --patch 5
2025.09.15-5
# Auto-increment from last version
$ calver bump --last "2025.09.15-3"
2025.09.15-4 # if same date
2025.09.16-0 # if different date
# Using environment variables
$ export CALVER_FORMAT="%Y%m%d"
$ export CALVER_SEPARATOR="_v"
$ calver bump
20250915_v0
calver bump [OPTIONS]
| Option | Short | Environment Variable | Description | Default |
|---|---|---|---|---|
--format |
-f |
CALVER_FORMAT |
Date format string | %Y.%m.%d |
--separator |
-s |
CALVER_SEPARATOR |
Separator between date and patch | - |
--patch |
-p |
CALVER_PATCH |
Explicit patch number (conflicts with --last) | 0 |
--last |
-l |
CALVER_LAST |
Previous version for auto-increment | None |
| Format | Output | Description |
|---|---|---|
%Y.%m.%d |
2024.03.15 |
Year.Month.Day (default) |
%Y%m%d |
20240315 |
Compact YYYYMMDD |
%y.%m.%d |
24.03.15 |
Short year format |
%Y-%m-%d |
2024-03-15 |
ISO date format |
%Y.%j |
2024.075 |
Year and day of year |
| Separator | Output | Description |
|---|---|---|
- |
2024.03.15-0 |
Hyphen (default) |
_ |
2024.03.15_0 |
Underscore |
. |
2024.03.15.0 |
Dot |
_v |
2024.03.15_v0 |
Version prefix |
The --last parameter enables intelligent patch increment:
Same date: Extracts and increments the patch number
calver bump --last "2024.03.15-3"
# Output: 2024.03.15-4
Different date: Resets patch to 0
calver bump --last "2024.03.14-10"
# Output: 2024.03.15-0
Invalid format: Ignores and uses default patch
calver bump --last "invalid-version"
# Output: 2024.03.15-0
Set default values using environment variables:
export CALVER_FORMAT="%Y%m%d"
export CALVER_SEPARATOR="_v"
export CALVER_PATCH="1"
calver bump
# Output: 20240315_v1
For CI/CD pipelines:
export CALVER_LAST=$(git tag -l --sort=-version:refname | head -n1)
calver bump
# Monday 2025.03.15
calver bump --last "2025.09.12-5"
# Output: 2025.03.15-0 (new day, reset patch)
# Later same day
calver bump --last "2024.03.15-0"
# Output: 2024.03.15-1
# Compact format for internal builds
calver bump --format "%y%m%d" --separator "."
# Output: 240315.0
# GitHub Actions example
- name: Generate Version
run: |
LAST_VERSION=$(git tag -l --sort=-version:refname | head -n1)
NEW_VERSION=$(calver bump --last "$LAST_VERSION")
echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV
echo "Generated version: $NEW_VERSION"
#!/bin/bash
# build.sh - Automated build with versioning
set -e
# Get last version from a file
LAST_VERSION=$(cat version.txt 2>/dev/null || echo "")
# Generate new version
NEW_VERSION=$(calver bump --last "$LAST_VERSION")
# Save for next build
echo "$NEW_VERSION" > version.txt
# Build with version
echo "Building version: $NEW_VERSION"
echo "✅ Build completed: $NEW_VERSION"
CalVer provides clear error messages and appropriate exit codes:
0: Success1: Error (patch overflow, invalid input)# Patch overflow
calver bump --last "2024.03.15-65535"
# Error: The patch calculated exceeds the maximum allowed value (65535)
# Exit code: 1
# Success case
calver bump --format "%Y.%m.%d"
# Output: 2024.03.15-0
# Exit code: 0
Clone the source repository: git clone https://gitlab.com/op_so/projects/calver.git
To format and lint:
cargo fmt # cargo fmt -- --check
cargo clippy # Rust linter
cargo build && cargo test # Unit and integration tests
cargo tarpaulin --ignore-tests # Code coverage
cargo audit # Security audit
cargo bench # Statistics-driven benchmarking
To run: cargo run
To build:
cargo build # Debug binary target/debug/calver
cargo build --release # Release binary target/release/calver
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
rustfmt and clippy recommendationsThis program is free software: you can redistribute it and/or modify it under the terms of the MIT License (MIT). See the LICENSE for details.