Skip to content

Commit

Permalink
update get_version_from_git.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanotorresi committed Dec 16, 2024
1 parent 94973b4 commit e9a7dc6
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions .ci/get_version_from_git.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/bin/sh
TAG=$(git describe --tags --abbrev=0 2>/dev/null)
SUFFIX=$(git show -s --format=%ct.%h HEAD)
TAG=$(git tag | grep -E "[0-9]\.[0-9]\.[0-9]" | sort -rn | head -n1)

if [ -n "${TAG}" ]; then
COMMITS_SINCE_TAG=$(git rev-list ${TAG}.. --count)
if [ "${COMMITS_SINCE_TAG}" -gt 0 ]; then
SUFFIX="dev${COMMITS_SINCE_TAG}.${SUFFIX}"
fi
if [ -z "${TAG}" ]; then
echo "Could not find any tag" 1>&2
exit 1
else
TAG="0"
COMMITS_SINCE_TAG=$(git rev-list "${TAG}".. --count)
if [ "${COMMITS_SINCE_TAG}" -gt 0 ]; then
COMMIT_INFO=$(git show -s --format=%ct.%h HEAD)
SUFFIX="+git.${COMMITS_SINCE_TAG}.${COMMIT_INFO}"
fi
fi

echo "${TAG}+git.${SUFFIX}"
echo "${TAG}${SUFFIX}"

0 comments on commit e9a7dc6

Please sign in to comment.