A CLI tool to automatically generate semantic versions based on Git commit history using Conventional Commits specification.
go install github.com/TheScenery/sem-version@latestmacOS (Apple Silicon)
curl -sSL https://github.com/TheScenery/sem-version/releases/latest/download/sem-version-darwin-arm64 -o /usr/local/bin/sem-version && chmod +x /usr/local/bin/sem-versionmacOS (Intel)
curl -sSL https://github.com/TheScenery/sem-version/releases/latest/download/sem-version-darwin-amd64 -o /usr/local/bin/sem-version && chmod +x /usr/local/bin/sem-versionLinux (amd64)
curl -sSL https://github.com/TheScenery/sem-version/releases/latest/download/sem-version-linux-amd64 -o /usr/local/bin/sem-version && chmod +x /usr/local/bin/sem-versionLinux (arm64)
curl -sSL https://github.com/TheScenery/sem-version/releases/latest/download/sem-version-linux-arm64 -o /usr/local/bin/sem-version && chmod +x /usr/local/bin/sem-versionWindows (PowerShell)
Invoke-WebRequest -Uri https://github.com/TheScenery/sem-version/releases/latest/download/sem-version-windows-amd64.exe -OutFile $env:USERPROFILE\bin\sem-version.exegit clone https://github.com/TheScenery/sem-version.git
cd sem-version
go build -o sem-versionWant to see it in action? Run the included demo script:
Windows (PowerShell):
.\demo.ps1macOS / Linux:
./demo.shThis script will:
- Build the tool locally
- Create a temporary git repository
- Simulate various commit scenarios (feat, fix, breaking change)
- Show you the generated versions
# Generate next version for current repository
sem-version
# With verbose output
sem-version --verbose
# Output without 'v' prefix
sem-version --no-prefix
# Specify repository path
sem-version --path /path/to/repo
# Custom prefix
sem-version --prefix "ver"
# Generate default config file
sem-version --init
# Use custom config file
sem-version --config /path/to/.sem-version.yamlGenerate a default config file with sem-version --init, which creates .sem-version.yaml:
# Major version bump (breaking changes)
major:
- '^.+!:' # type!: breaking change
- 'BREAKING CHANGE:' # in commit body
# Minor version bump (new features)
minor:
- '^feat(\(.+\))?:' # feat: or feat(scope):
# Patch version bump (bug fixes)
patch:
- '^fix(\(.+\))?:' # fix:
- '^hotfix(\(.+\))?:' # hotfix:
- '^refactor(\(.+\))?:' # refactor:
- '^perf(\(.+\))?:' # perf:Each section contains regex patterns to match commit messages. Customize patterns to fit your workflow.
This tool follows the Conventional Commits specification:
| Commit Type | Version Bump | Example |
|---|---|---|
feat |
Minor | feat: add user login |
fix |
Patch | fix: resolve null pointer |
refactor |
Patch | refactor: clean up code |
perf |
Patch | perf: optimize query |
feat! |
Major | feat!: breaking API change |
BREAKING CHANGE |
Major | (in commit body) |
# Starting from no tags
git commit -m "feat: initial implementation"
sem-version
# Output: v0.1.0
# After tagging v0.1.0
git commit -m "fix: bug fix"
sem-version
# Output: v0.1.1
git commit -m "feat: new feature"
sem-version
# Output: v0.2.0
git commit -m "feat!: breaking change"
sem-version
# Output: v1.0.0- Finds the latest semantic version tag (e.g.,
v1.2.3) - Collects all commits since that tag
- Parses each commit message using Conventional Commits format
- Calculates the next version based on commit types:
- BREAKING CHANGE → Major bump (reset minor and patch)
- feat → Minor bump (reset patch)
- fix/refactor/perf → Patch bump
MIT