Skip to content

Commit

Permalink
Fix version script (#124)
Browse files Browse the repository at this point in the history
Copied over the script from submariner for calculating the image version
  • Loading branch information
mkolesnik authored May 7, 2020
1 parent bcfc813 commit 910dd03
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions scripts/lib/version
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/bin/bash

# This should only be sourced
if [ "${0##*/}" = "version" ]; then
echo "Don't run me, source me" >&2
exit 1
fi

if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
DIRTY="-dirty"
fi

COMMIT=$(git rev-parse --short HEAD)
GIT_TAG=$(git tag -l --contains HEAD | head -n 1)

if [[ -n "$GIT_TAG" ]]; then
VERSION=${GIT_TAG#"v"}
if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then
VERSION=$GIT_TAG
else
VERSION="dev"
fi
fi

0 comments on commit 910dd03

Please sign in to comment.