Skip to content

Git extension to easily manage your project's version based on Semantic Versioning and Conventional Commits

License

Notifications You must be signed in to change notification settings

carlsberg/git-semver

Repository files navigation

git-semver

Build LoC

Git extension to easily manage your project's version based on Semantic Versioning and Conventional Commits

Install

Using Brew

$ brew install carlsberg/tap/git-semver

From source

Requires go >= 1.16.

$ go install github.com/carlsberg/git-semver@latest

Commands

git semver bump

Bumps the latest version to the next version, creates a tag and pushes it to origin.

Options:

Name Description
-P, --password Password to use in HTTP basic authentication (useful for CI/CD pipelines)
-u, --username Username to use in HTTP basic authentication (useful for CI/CD pipelines)
-f, --version-file Version files that should be updated. Format should be filename:key
--v-prefix Prefix the version with a v
--skip-tag Don't create a new tag automatically

Example:

$ git commit -am "fix: something important"
$ git semver bump -f package.json:version
bump from 0.0.0 to 0.0.1

git semver latest

Outputs the latest released version.

Example:

$ git semver latest
0.0.1

git semver next

Outputs the next unreleased version.

Options:

Name Description
--v-prefix Prefix the version with a v

Example:

$ git commit -am "feat: neat feat"
$ git semver next
0.1.0

Monorepos Support

Git SemVer supports monorepos with multiple projects through the -p, --project option. For example, imagine you've a repository with a project in libs/xyz that you want to version independently:

$ git commit -am "feat: awesome xyz lib"
$ git bump -p libs/xyz -f package.json:version
bump libs/xyz from 0.0.0 to 0.1.0
# creates a tag `libs/xyz/0.1.0`

Usage in GitHub Actions

The following example shows a workflow using git-semver in GitHub Actions:

name: Bump

jobs:
  bump:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - uses: carlsberg/git-semver@v0.5.0
        with:
          script: |
            echo "Latest Version: $(git semver latest)"
            echo "Next Version: $(git semver next)"
            
            git semver bump -u ${{ github.actor }} -P ${{ github.token }}

License

This project is released under the MIT License.

About

Git extension to easily manage your project's version based on Semantic Versioning and Conventional Commits

Topics

Resources

License

Stars

Watchers

Forks

Languages