Coder Social home page Coder Social logo

git-describe-semver's Introduction

git-describe-semver

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

Comparison

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

Next Release

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

Usage

  • 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 (like v) 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 to dev)
  • 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)

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 }}

git-describe-semver's People

Contributors

choffmeister avatar cgrindel avatar gregmagolan avatar reneleonhardt avatar thorgull avatar

Stargazers

Justin Middler avatar  avatar Dwi Siswanto avatar Sangbum kim avatar Daniel avatar  avatar Hung-Wei (David) Hsu avatar  avatar Michael Haselton avatar David Vins avatar Dave Henderson avatar Rollulus Rouloul avatar Elliot DeNolf avatar WillAbides avatar  avatar Ben Kolb avatar Matt Gowie avatar Erik Kristensen avatar Adam Chalkley avatar Mikhail S avatar Tom Carrio avatar Jannes Meyer avatar Nick Mazuk avatar  avatar Ramon Buckland avatar Iaroslav Voloshchuk avatar Olve Hansen avatar Nick Ng avatar Gabriel Nützi avatar Tam Nguyen avatar

Watchers

 avatar James Cloos avatar

git-describe-semver's Issues

Use of the plus sign

Hey,

We use the + sign to append metadata as explained in https://semver.org/#spec-item-10

So if a git describe --abbrev=7 yields: v2.0.0-rc.7-1-g922ac4b
Ghis project yields: v2.0.0-rc.7.dev.1.g922ac4b
I would like the result to be v2.0.0-rc.7+1.922ac4b

That requires:

  1. make this project supports the + sign.
  2. make it possible to skip prerelease prefix

Would it be possible to support this?

Thanks.

Action fails due to argument passed to --drop-prefix

The action fails with the following top level message on GitHub CI.
The issue is observed 0.3.11 as well as 0.4.0.
However the issue is fixed on the main branch - that is @main works

    uses: choffmeister/git-describe-semver@main
Github Action Logs

Run choffmeister/[email protected]
  with:
    fallback: 0.0.0
    prerelease-prefix: pre
    prerelease-timestamped: false
    version: latest
    dir: .
    drop-prefix: false
Run cd /tmp
  cd /tmp
  URL=$(curl -fsSL https://api.github.com/repos/choffmeister/git-describe-semver/releases/latest | jq -r '.assets[] | select(.name|test("linux_amd64\\.tar\\.gz$")) | .browser_download_url')
  curl -fsSL "$URL" | tar xz
  mv git-describe-semver /usr/local/bin
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
Run git-describe-semver \
  git-describe-semver \
    --dir="." \
    --fallback="0.0.0" \
    --drop-prefix="false" \
    --prerelease-prefix="pre" \
    --prerelease-suffix="" \
    --prerelease-timestamped="false" \
     \
    --format="version=<version>" \
    $GITHUB_OUTPUT
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
bool flag `--drop-prefix' cannot have an argument
Error: Process completed with exit code 1.

The workflow job is as follows

jobs:
  get_version:
    name: Get Build Version
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
        with:
          submodules: 'true'
          fetch-depth: 0
          set-safe-directory: 'true'

      - id: git_describe_semver
        uses: choffmeister/[email protected]
        with:
          fallback: 0.0.0
          prerelease-prefix: pre
          prerelease-suffix: ''
          prerelease-timestamped: false

Could you please tag this release so that I could refer to it specifically. Also, it was a surprise that a later commit broke 0.3.11. Perhaps the action always pulls the latest docker image. Any help for this would be greatly appreciated.

typo help command

Usage of git-describe-semver:
  -drop-prefix
    	Drop prefix from output
  -fallback string
    	The first version to fallback to should there be no tag
  -format string
    	Format of output
  -prerelease-suffix string
    	Suffix to add to prereleases

--drop-prefix
--fallback
--format
--prerelease-suffix string

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.