Replacement for git describe --tags
that produces semver compatible versions that follow to semver sorting rules.
Previous git tag | git describe --tags | git-describe-semver --fallback v0.0.0 |
---|---|---|
v1.2.3 |
v1.2.3 |
v1.2.3 |
v1.2.3 |
v1.2.3-23-gabc1234 |
v1.2.4-dev.23.gabc1234 |
v1.3.0-rc.1 |
v1.3.0-rc.1-23-gabc1234 |
v1.3.0-rc.1.dev.23.gabc1234 |
v1.3.0-rc.1+info |
v1.3.0-rc.1+info-23-gabc1234 |
v1.3.0-rc.1.dev.23.gabc1234+info |
none | fail | v0.0.0-dev.23.gabc1234 |
Previous git tag | git describe --tags | git-describe-semver --fallback v0.0.0 | --next-release |
---|---|---|---|
v1.2.3 |
v1.2.3 |
v1.2.4 |
patch |
v1.2.3 |
v1.2.3-23-gabc1234 |
v1.2.4 |
patch |
v1.3.0-rc.1 |
v1.3.0-rc.1-23-gabc1234 |
v1.3.0 |
patch / minor |
v1.3.1-rc.1 |
v1.3.1-rc.1-23-gabc1234 |
v1.4.0 |
minor |
v1.0.0-rc.1 |
v1.0.0-rc.1-23-gabc1234 |
v1.0.0 |
major |
v1.0.0 |
v1.0.0 |
v2.0.0 |
major |
v1.0.1-rc.1 |
v1.0.1-rc.1-23-gabc1234 |
v2.0.0 |
major |
none | fail | v0.0.0 |
patch / minor / major |
- Flag
--dir /some/git/worktree
: Git worktree directory (defaults to current directory.
) - Flag
--fallback v0.0.0
: Fallback to given tag name if no tag is available - Flag
--drop-prefix
: Drop any present prefix (likev
) from the output - Flag
--prerelease-suffix
: Adds a dash-separated suffix to the prerelease part - Flag
--prerelease-prefix
: Adds a dash-separated prefix to the prerelease part (defaults todev
) - Flag
--prerelease-timestamped
: Use timestamp instead of commit count for prerelease - Flag
--next-release
: Bump current version to next release (choices:major
,minor
,patch
) - Flag
--format
: Changes output (use<version>
as placeholder)
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/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 }}