https://github.com/indaco/semver-cli
A simple CLI to manage semantic versioning using a .version file.
https://github.com/indaco/semver-cli
cli go golang semantic-versioning semver versioning
Last synced: over 1 year ago
JSON representation
A simple CLI to manage semantic versioning using a .version file.
- Host: GitHub
- URL: https://github.com/indaco/semver-cli
- Owner: indaco
- License: mit
- Created: 2025-03-23T23:53:13.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-24T01:18:11.000Z (over 1 year ago)
- Last Synced: 2025-03-24T01:23:27.412Z (over 1 year ago)
- Topics: cli, go, golang, semantic-versioning, semver, versioning
- Language: Go
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
semver
A simple CLI to manage semantic versioning using a .version file.
## π Table of Contents
- [β¨ Features](#-features)
- [π» Installation](#-installation)
- [π οΈ CLI Commands & Options](#οΈ-cli-commands--options)
- [βοΈ Configuration](#οΈ-configuration)
- [π Auto-initialization](#-auto-initialization)
- [π Usage](#-usage)
- [π€ Contributing](#-contributing)
- [π License](#-license)
## β¨ Features
- Bump patch, minor, or major versions
- Add or update pre-release labels (`alpha`, `beta.1`, etc.)
- Auto-increment pre-release versions
- Show current version
## π» Installation
#### Option 1: Install via `go install` (global)
```bash
go install github.com/indaco/semver-cli/cmd/semver@latest
```
#### Option 2: Install via `go install` (tool)
With Go 1.24 or greater installed, you can install `semver` locally in your project by running:
```bash
go get -tool github.com/indaco/semver-cli/cmd/semver@latest
```
Once installed, use it with
```bash
go tool semver
```
#### Option 3: Prebuilt binaries
Download the pre-compiled binaries from the [releases page](https://github.com/indaco/semver/releases) and place the binary in your systemβs PATH.
#### Option 4: Clone and build manually
```bash
git clone https://github.com/indaco/semver-cli.git
cd semver-cli
make install # or task install
```
## π οΈ CLI Commands & Options
```bash
NAME:
semver - Manage semantic versioning with a .version file
USAGE:
semver [global options] [command [command options]]
VERSION:
v0.1.1
COMMANDS:
patch Increment patch version
minor Increment minor version and reset patch
major Increment major version and reset minor and patch
pre Set pre-release label (e.g., alpha, beta.1)
show Display current version
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--path value, -p value Path to .version file (default: ".version")
--help, -h show help
--version, -v print the version
```
## βοΈ Configuration
The CLI determines the `.version` path in the following order:
1. `--path` flag
2. `SEMVER_PATH` environment variable
3. `.semver.yaml` file
4. Fallback: `.version` in the current directory
**Example: Use Environment Variable**
```bash
export SEMVER_PATH=./my-folder/.version
semver patch
```
**Example: Use .semver.yaml**
```bash
# .semver.yaml
path: ./my-folder/.version
```
If both are missing, the CLI uses .version in the current directory.
## π Auto-initialization
If the `.version` file does not exist when running the CLI:
1. It tries to read the latest Git tag via `git describe --tags`.
2. If the tag is a valid semantic version, it is used.
3. Otherwise, the file is initialized to 0.1.0.
This ensures your project always has a starting point.
## π Usage
**Show the current version**
```bash
# .version = 1.2.3
semver show
# => 1.2.3
```
**Bump patch version**
```bash
# .version = 1.2.3
semver patch
# => 1.2.4
```
**Bump minor version (and reset patch to 0)**
```bash
# .version = 1.2.3
semver minor
# => 1.3.0
```
**Bump major version (and reset minor/patch to 0)**
```bash
# .version = 1.2.3
semver major
# => 2.0.0
```
**Set a pre-release label**
```bash
# .version = 0.2.1
semver pre --label alpha
# => 0.2.2-alpha
```
If a pre-release is already present, itβs replaced:
```bash
# .version = 0.2.2-beta.3
semver pre --label alpha
# => 0.2.2-alpha
```
**Auto-increment pre-release label**
```bash
# .version = 1.2.3-alpha.1
semver pre --label alpha --inc
# => 1.2.3-alpha.2
```
```bash
# .version = 1.2.3
semver pre --label alpha --inc
# => 1.2.3-alpha.1
```
## π€ Contributing
Contributions are welcome!
See the [Contributing Guide](/CONTRIBUTING.md) for setting up the development tools.
## π License
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.