(c) by Ralph Roth, ROSE SWE
verinc is a robust, lightweight command-line utility written in Go (v1.25++) designed to automate the management of version strings within source code. It targets specific lines containing version tokens and applies custom incrementation rules, making it ideal for build pipelines and release management.
Note
We use this tool in-house for various projects e.g. for cfg2html or getrpm (both available on github too).
- Smart Versioning: Automatically handles
MAJOR.MINOR.PATCHincrements. - Token-Based Selection: Processes only lines containing specific markers like
_VERSION,ProductVersion, orFileVersion. - Overflow Logic: Implements a custom rule where reaching a PATCH of 10 resets it to 1 and increments the MINOR version.
- Multi-File Support: Update multiple source files in a single command.
- Detailed Feedback: Verbose mode provides a clear "old -> new" transition log for every change.
- Standard Library: Built using only the Go standard library for maximum portability.
While verinc follows a custom overflow rule (e.g., 3.19.9 → 3.20.1), it is fundamentally designed to support the structure of Semantic Versioning (SemVer).
The tool operates on the standard MAJOR.MINOR.PATCH format:
- MAJOR: Incremented for incompatible changes. Use
-jor--major. - MINOR: Incremented for added functionality. Use
-mor--minor. - PATCH: Incremented for backwards-compatible bug fixes. This is the default behavior.
verinc is language-agnostic and processes files based on line content rather than extension.
- Source Code:
- Pascal/Delphi/Lazarus: Updates constants or comments marked with
_VERSION. - Go/C/C++: Updates string constants or header macros.
- Pascal/Delphi/Lazarus: Updates constants or comments marked with
- Windows Resource Files (
.rc): TargetsFILEVERSIONandPRODUCTVERSIONdefinitions. - Compiler & Build Metadata:
- JSON Configs: Updates
ProductVersion,Version, orFileVersionkeys found inpackage.jsonor manifests. - Project Files: Updates XML or plain-text metadata used by compilers.
- JSON Configs: Updates
verinc [options] file1 [file2 ...]| Short | Long | Description |
|---|---|---|
-?, -h |
--help |
Show detailed help and documentation. |
-V |
--version |
Show current version of the verinc tool. |
-v |
--verbose |
Enable verbose output (shows specific line changes). |
-g |
--get |
Return the first matching version string to stdout (useful for Makefiles/scripts). |
-m |
--minor |
Bump MINOR version and reset PATCH to 1. |
-j |
--major |
Bump MAJOR version and reset MINOR/PATCH to 0/1. |
verinc returns specific exit codes for easy integration with CI/CD scripts:
0: Success ✅1: Generic error2: Invalid command line arguments3: No files provided4: File open/read error5: No version tokens (_VERSION, etc.) found in any file6: Version string parse error7: File write error
Basic patch increment:
verinc main.pasMinor version jump with verbose output:
verinc -m -v ~/src/project/version.goUpdating multiple files at once:
verinc -v config.json constants.pas README.mdGet first matching version string (for Makefiles/Bash scripts):
verinc --get version.go
# Output: 2.05
# Useful in Makefiles or shell scripts:
VER=$(verinc -g main.pas)
echo "Version is $VER"Build directly from the source using Go:
go build -o verinc verinc.goPush a version tag to start the GitHub Actions build:
- Commit all:
git commit -a -s -m "..." - Tag:
git tag v2.0.5 - Push:
git push origin v2.0.5
// end of document