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 20, 2024
1 parent e3b5eac commit c1eda0f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .ci/get_version_from_git.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/bin/sh
TAG=$(git tag | grep -E "[0-9]\.[0-9]\.[0-9]" | sort -rn | head -n1)

# https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
SEMVER_REGEX="^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"

TAG=$(git tag | grep -P "$SEMVER_REGEX" | sed '/-/!{s/$/_/}' | sort -V | sed 's/_$//' | tail -n1)

if [ -z "${TAG}" ]; then
echo "Could not find any tag" 1>&2
echo "Could not find any semver tag" 1>&2
exit 1
else
COMMITS_SINCE_TAG=$(git rev-list "${TAG}".. --count)
Expand Down

0 comments on commit c1eda0f

Please sign in to comment.