Skip to content

Commit 242f46e

Browse files
committed
chore: always use the latest released version tag when building
1 parent ba7d183 commit 242f46e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

scripts/version.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ if ! [[ ${remote_url} =~ [@/]github.com ]] && ! [[ ${remote_url} =~ [:/]coder/co
4141
log
4242
last_tag="v2.0.0"
4343
else
44-
last_tag="$(git describe --tags --abbrev=0)"
44+
current_commit=$(git rev-parse HEAD)
45+
# Try to find the last tag that contains the current commit
46+
last_tag=$(git tag --contains ${current_commit} --sort=version:refname | head -n 1)
47+
# If there is no tag that contains the current commit,
48+
# get the latest tag sorted by semver.
49+
if [[ -z "${last_tag}" ]]; then
50+
last_tag=$(git tag --sort=version:refname | tail -n 1)
51+
fi
4552
fi
4653

4754
version="${last_tag}"

0 commit comments

Comments
 (0)