A semantic version management CLI that keeps a version in a plain text VERSION file and stamps, bumps, releases and embeds it.
Documentation: https://benjaminabbitt.github.io/versionator/
- Single source of truth: a plain text
VERSIONfile, bare SemVer 2.0.0 - A stamp for every build:
versionator output versionprintsv1.2.3on a clean tag andv1.2.4-dev.5+g1a2b3c4past it (with the UTC datetime in the metadata when the tree is dirty), in the shape setuptools_scm uses, in SemVer - Deliberate or automatic bumps:
bump minor increment, orbumpalone to read the commits since the latest tag (+semver:markers, Conventional Commits); counted from the tag, so running it twice changes nothing - Releases:
releasecommits VERSION and the files it syncs, tagsv<version>and makes the release branch;release pushsends the tag and the branch in one atomic push - Manifest sync:
updates:in.versionator.yamlwrites the version intopackage.json,Cargo.toml,Chart.yaml, ... editing only the version value, comments and layout kept - Code embedding:
output emitgenerates version constants for 18 formats - CI/CD integration:
output ciprints variables for GitHub Actions, GitLab CI, Azure, CircleCI, Jenkins and the shell - A configuration its commands edit:
config prefix,custom,stamp,dirty,release,updates; the file keeps its comments
Generate version constants for your codebase (sorted by TIOBE Index):
| Language | Format | Documentation |
|---|---|---|
| Python | python |
_version.py |
| C | c, c-header |
version.c, version.h |
| C++ | cpp, cpp-header |
version.cpp, version.hpp |
| Java | java |
Version.java |
| C# | csharp |
Version.cs |
| JavaScript | js |
version.js |
| Go | go |
version.go |
| TypeScript | ts |
version.ts |
| PHP | php |
Version.php |
| Swift | swift |
Version.swift |
| Kotlin | kotlin |
Version.kt |
| Rust | rust |
version.rs |
| Ruby | ruby |
version.rb |
Data formats: JSON (json), YAML (yaml) — see emit command
Container files: Docker — Containerfile/Dockerfile with OCI labels
Full documentation: https://benjaminabbitt.github.io/versionator/
Each release is a GitHub release with archives for Linux, macOS and Windows,
an install.sh and install.ps1, and SHA256SUMS:
curl -fsSL https://github.com/benjaminabbitt/versionator/releases/latest/download/install.sh | shOr build it from source (rust-toolchain.toml names the toolchain):
cargo install --path crates/root/bin/versionatorSee Installation for all platforms.
versionator init # a VERSION file (0.0.1)
versionator bump patch increment # 0.0.1 -> 0.0.2
versionator release # commit VERSION, tag v0.0.2, branch release/v0.0.2
versionator output version # the stamp: v0.0.2 on the tagOff a terminal the answer is JSON. In a script ask for the plain text:
VERSION=$(versionator --format text output version)
eval "$(versionator --format text output ci --provider shell)"--detailed-exitcode makes a success exit 16; failures exit 32-47 and refusals
(a command that cannot be done in this state, or a usage error) 48-63.
To check the stamp from a git hook, run it from lefthook (there is no
init hook):
# lefthook.yml
pre-push:
commands:
version:
run: versionator --format text output versionThe configuration of the Go program (.versionator.yaml with no
schema_version) is read as it was and carried to schema 1 when a config
command writes it. Template variables are snake_case now
({{major_minor_patch}}); the old names still render, with a warning. See
tests/PARITY.md for every
change and the decision behind it.
Everything goes through just: just rust-build, just rust-test (unit tests and
the acceptance checklist), just rust-lint, just rust-mutants-paths crates.
just rust-set-version <v> writes a version with this repository's own binary,
and the tag v<v> cuts the release (.github/workflows/release.yml).
Versionator is a hobby project solving a real problem. It could be solved with less—a regex parses most version strings just fine. Instead, there's a 370-line formal EBNF grammar covering SemVer, Go pseudo-versions, .NET assembly versions, and more. Written on a Sunday afternoon because formal grammars are fun and passion projects permit glorious digressions.
The grammar might have value to someone, sometime. If it doesn't, that's fine too. It has value to me.
See Grammar-Based Parser for the full philosophy.
Apache-2.0 OR BSD-3-Clause, at your option: see LICENSE-APACHE and LICENSE-BSD.