github.com/rancher/types@v0.0.0-20220328215343-4370ff10ecd5/scripts/version (about)

     1  #!/bin/bash
     2  
     3  if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
     4      DIRTY="-dirty"
     5  fi
     6  
     7  COMMIT=$(git rev-parse --short HEAD)
     8  GIT_TAG=$(git tag -l --contains HEAD | head -n 1)
     9  
    10  if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
    11      VERSION=$GIT_TAG
    12  else
    13      VERSION="${COMMIT}${DIRTY}"
    14  fi
    15  
    16  if [ -z "$ARCH" ]; then
    17      ARCH=amd64
    18  fi