Skip to content

Manage project's semantic version alongside git tag.

License

Notifications You must be signed in to change notification settings

adharshmk96/semver

Repository files navigation

semver - Semantic Version Management CLI

semver offers a streamlined command-line experience to implement semantic versioning for your projects seamlessly. Whether you utilize git tags or prefer a .version file for non-git projects, semver has got you covered.

Go Report Card Build and Test GitHub release (latest by date) GitHub go.mod Go version

Key Features

  • Standard version format: MAJOR.MINOR.PATCH (e.g., 1.0.0)
  • Supports pre-release versions with MAJOR.MINOR.PATCH-PRERELEASE format (e.g., 1.0.0-alpha.1)

🛠 Installation

Direct Binary Download

Linux:

VERSION="1.2.2" && \
TMP_FILE="/tmp/semver_$VERSION_linux_amd64.tar.gz" && \
curl -sLo $TMP_FILE https://github.com/adharshmk96/semver/releases/download/v$VERSION/semver_$VERSION_linux_amd64.tar.gz && \
sudo tar xz -C /usr/local/bin -f $TMP_FILE semver && \
rm $TMP_FILE
  1. Download from the releases page.
  2. Decompress and Move binary to /usr/local/bin or any directory in your PATH.

Using Golang

go install github.com/adharshmk96/semver@latest

Note: Ensure Golang is properly set up and that GOPATH is configured in your PATH.

🚀 Getting Started

Initialize Your Project

Start a new project with the following, optionally specifying the version:

semver init        # Default initialization
semver init v1.0.0 # With v1.0.0 version

Note: Initialization is unnecessary if you're already using git tags for versioning.

Retrieve Current Version

semver get

📖 Version Management

Standard Release Versions

Easily increment version numbers:

semver major    # v1.0.0 -> v2.0.0
semver minor    # v1.0.0 -> v1.1.0
semver patch    # v1.0.0 -> v1.0.1

For pre-releases, append the desired flag:

semver major --alpha  # v1.0.0 -> v2.0.0-alpha.1
semver minor --beta   # v1.0.0 -> v1.1.0-beta.1
semver patch --rc     # v1.0.0 -> v1.0.1-rc.1

Pre-Release Versions

Manage pre-release versions effortlessly:

semver alpha  # v1.0.0-alpha.1 -> v1.0.0-alpha.2
semver beta   # v1.0.0-beta.1  -> v1.0.0-beta.2
semver rc     # v1.0.0-rc.1    -> v1.0.0-rc.2

Tip: use --push or -p flag to push the latest tag to remote repository along with version update command.

Note: Direct pre-release updates on a release version will fail. First, create a pre-release as shown above.

Transition to a Full Release

Strip pre-release tags:

semver release  # v1.0.0-alpha.2 -> v1.0.0

📝 Auxiliary Commands

Removing Git Tags

remove latest tag:

semver untag

remove specific tag:

semver untag v1.0.0

add --remote flag to remove remote tag as well.

Pushing Git Tags

semver push

Pushes latest tag to remote repository. git push origin <current tag> is executed under the hood.

Resetting Versions

Easily revert to a specified version or default to v0.0.1:

Local:

semver reset        # v1.2.3 -> v0.0.1
semver reset v1.0.0 # v1.2.3 -> v1.0.0

Remote:

semver reset --remote        # v1.2.3 -> v0.0.1
semver reset v1.0.0 --remote # v1.2.3 -> v1.0.0

⚠️ Caution: Understand the implications of reset to avoid unintended data loss.

License

Licensed under the MIT License.

🤝 Support & Feedback

For any support, queries, or feedback, feel free to reach out at [email protected].

About

Manage project's semantic version alongside git tag.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages