Skip to content

Commit 1ca5dc0

Browse files
chore: always use the latest released version tag when building (#13556)
* chore: always use the latest released version tag when building * Update version.sh Co-authored-by: Dean Sheather <dean@deansheather.com> --------- Co-authored-by: Dean Sheather <dean@deansheather.com>
1 parent 28228f1 commit 1ca5dc0

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)