Skip to main content Miguel Hernández

Semantic Versioning Made Easy With Svu

TL;DR
svu is a lightweight CLI tool that generates semantic versions based on your Git log and follows Conventional Commits. It is the perfect companion for GoReleaser.

Automating semantic versioning can be cumbersome, especially when dealing with CI/CD pipelines. svu simplifies this by:

  • Automatically determining the next semantic version based on Git commits.
  • Supporting Conventional Commits to derive version increments (major, minor, patch).
  • Being lightweight, portable, and designed for seamless integration with Go projects and GoReleaser.

Examples

Get the next version

If your Git repository follows Conventional Commits, you can run:

shell code snippet start

svu next

shell code snippet end

This will output the next semantic version based on your commit history. For example, if your last version was v1.2.3 and you made a commit with feat: add new API, this command will return v1.3.0.

Bump a specific version

If you want to manually specify the next version type, you can do from an existing v1.2.3 version:

shell code snippet start

svu patch # Outputs the next patch version, e.g., v1.2.4
svu minor # Outputs the next minor version, e.g., v1.3.0
svu major # Outputs the next major version, e.g., v2.0.0

shell code snippet end

Using with GoReleaser

GoReleaser does not create any tags, it just runs on what is already there. You can integrate svu to automatically determine the version:

shell code snippet start

git tag "$(svu next)"
git push --tags
goreleaser release --clean # Or run this in CI/CD (e.g., GitHub Actions)

shell code snippet end

This ensures that every release follows semantic versioning without manual intervention.