Home

Awesome

git-describe-semver

Replacement for git describe --tags that produces semver compatible versions that follow to semver sorting rules.

Comparison

Previous git taggit describe --tagsgit-describe-semver --fallback v0.0.0
v1.2.3v1.2.3v1.2.3
v1.2.3v1.2.3-23-gabc1234v1.2.4-dev.23.gabc1234
v1.3.0-rc.1v1.3.0-rc.1-23-gabc1234v1.3.0-rc.1.dev.23.gabc1234
v1.3.0-rc.1+infov1.3.0-rc.1+info-23-gabc1234v1.3.0-rc.1.dev.23.gabc1234+info
nonefailv0.0.0-dev.23.gabc1234

Next Release

Previous git taggit describe --tagsgit-describe-semver --fallback v0.0.0--next-release
v1.2.3v1.2.3v1.2.4patch
v1.2.3v1.2.3-23-gabc1234v1.2.4patch
v1.3.0-rc.1v1.3.0-rc.1-23-gabc1234v1.3.0patch / minor
v1.3.1-rc.1v1.3.1-rc.1-23-gabc1234v1.4.0minor
v1.0.0-rc.1v1.0.0-rc.1-23-gabc1234v1.0.0major
v1.0.0v1.0.0v2.0.0major
v1.0.1-rc.1v1.0.1-rc.1-23-gabc1234v2.0.0major
nonefailv0.0.0patch / minor / major

Usage

Docker

cd my-git-directory
docker pull ghcr.io/choffmeister/git-describe-semver:latest
docker run --rm -v $PWD:/workdir ghcr.io/choffmeister/git-describe-semver:latest

GitHub action

# .github/workflows/build.yml
name: build
jobs:
  update:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
      with:
        fetch-depth: 0
    - id: git-describe-semver
      uses: choffmeister/git-describe-semver@main
      with:
        version: latest
        dir: .
        fallback: v0.0.0
        drop-prefix: true
        prerelease-prefix: dev
        prerelease-suffix: SNAPSHOT
        prerelease-timestamped: true
        next-release: ''
    - run: echo This is the version ${{ steps.git-describe-semver.outputs.version }}