Skip to content

Commit b1f17f4

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

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

scripts/version.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@ 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_branch=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)
45+
# When working from the `main` branch we assume that the latest
46+
# tag is the most recent release. We don't always release from
47+
# the main branch, so using `git describe --tags` doesn't work
48+
# for this scenario.
49+
if [[ "${current_branch}" == "main" ]]; then
50+
last_tag=$(git tag -l --sort=version:refname | tail -n 1)
51+
else
52+
last_tag="$(git describe --tags --abbrev=0)"
53+
fi
4554
fi
4655

4756
version="${last_tag}"

0 commit comments

Comments
 (0)