Skip to content

About

A small CLI to maintain a VERSION file for an application. That version file can track the semver of the application and the CLI nature of the application allows it to easily be integrated into build tooling.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

194 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Versionator

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/

Features

  • Single source of truth: a plain text VERSION file, bare SemVer 2.0.0
  • A stamp for every build: versionator output version prints v1.2.3 on a clean tag and v1.2.4-dev.5+g1a2b3c4 past 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, or bump alone to read the commits since the latest tag (+semver: markers, Conventional Commits); counted from the tag, so running it twice changes nothing
  • Releases: release commits VERSION and the files it syncs, tags v<version> and makes the release branch; release push sends the tag and the branch in one atomic push
  • Manifest sync: updates: in .versionator.yaml writes the version into package.json, Cargo.toml, Chart.yaml, ... editing only the version value, comments and layout kept
  • Code embedding: output emit generates version constants for 18 formats
  • CI/CD integration: output ci prints 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

Language Support

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

Documentation

Full documentation: https://benjaminabbitt.github.io/versionator/

Quick Install

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 | sh

Or build it from source (rust-toolchain.toml names the toolchain):

cargo install --path crates/root/bin/versionator

See Installation for all platforms.

Quick Start

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 tag

Off 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 version

From the Go version

The 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.

Building

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).

About This Project

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.

License

Apache-2.0 OR BSD-3-Clause, at your option: see LICENSE-APACHE and LICENSE-BSD.

About

A small CLI to maintain a VERSION file for an application. That version file can track the semver of the application and the CLI nature of the application allows it to easily be integrated into build tooling.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages