github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/tools/image-tag (about)

     1  #!/usr/bin/env bash
     2  
     3  set -o errexit
     4  set -o nounset
     5  set -o pipefail
     6  
     7  WIP=$(git diff --quiet || echo '-WIP')
     8  BRANCH=$(git rev-parse --abbrev-ref HEAD | sed 's#/#-#g')
     9  # When 7 chars are not enough to be unique, git automatically uses more.
    10  # We are forcing to 7 here, as we are doing for grafana/grafana as well.
    11  SHA=$(git rev-parse --short=7 HEAD | head -c7)
    12  
    13  # If not a tag, use branch-hash else use tag
    14  TAG=$((git describe --exact-match 2> /dev/null || echo "") | sed 's/v//g')
    15  
    16  if [ -z "$TAG" ]
    17  then
    18        echo "${BRANCH}"-"${SHA}""${WIP}"
    19  else
    20        echo "${TAG}"
    21  fi