Skip to content

Commit 66678c5

Browse files
authored
Merge pull request #10 from xmudrii/non-v0-tags-fix-2
Fix getting the latest commit/tag
2 parents a2992ce + ec96f2a commit 66678c5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

artifacts/scripts/util.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ gomod-pseudo-version() {
888888
commit_ts="$(TZ=UTC git show -s --date='format-local:%Y%m%d%H%M%S' --format=%cd HEAD)"
889889

890890
local commit_tag
891-
commit_tag="$(git describe --tags --exact-match --abbrev=0 2>/dev/null || true)"
891+
commit_tag="$( (git tag --points-at HEAD 2>/dev/null || true) | grep 'origin\/v' | sed 's|^origin/||' | sort -V | tail -n1)"
892892

893893
# latest commit has a tag -> tag
894894
if [[ -n "${commit_tag}" ]]; then
@@ -897,7 +897,7 @@ gomod-pseudo-version() {
897897
fi
898898

899899
local latest_tag
900-
latest_tag="$(git ls-remote --tags origin 2>/dev/null | awk -F/ '{print $3}' | grep -E '^v[0-9]+(\.[0-9]+)*$' | sort -V | tail -n1)"
900+
latest_tag="$( (git ls-remote --tags origin 2>/dev/null || true) | awk -F/ '{print $3}' | grep -v '\^{}' | grep 'v' | sort -V | tail -n1)"
901901

902902
# tag does not exist at all -> v0.0.0-<timestamp>-<hash>
903903
if [[ -z "${latest_tag:-}" ]]; then

0 commit comments

Comments
 (0)