Skip to content

Commit e9a7dc6

Browse files
author
Stefano Torresi
committed
update get_version_from_git.sh script
1 parent 94973b4 commit e9a7dc6

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

.ci/get_version_from_git.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/bin/sh
2-
TAG=$(git describe --tags --abbrev=0 2>/dev/null)
3-
SUFFIX=$(git show -s --format=%ct.%h HEAD)
2+
TAG=$(git tag | grep -E "[0-9]\.[0-9]\.[0-9]" | sort -rn | head -n1)
43

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

14-
echo "${TAG}+git.${SUFFIX}"
15+
echo "${TAG}${SUFFIX}"

0 commit comments

Comments
 (0)