From 242f46ef39116901183cb77fe771de7ea40407ef Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Wed, 12 Jun 2024 16:01:10 +0000 Subject: [PATCH 1/2] chore: always use the latest released version tag when building --- scripts/version.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/version.sh b/scripts/version.sh index eba2f63cbc40e..ea9f168d80d8c 100755 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -41,7 +41,14 @@ if ! [[ ${remote_url} =~ [@/]github.com ]] && ! [[ ${remote_url} =~ [:/]coder/co log last_tag="v2.0.0" else - last_tag="$(git describe --tags --abbrev=0)" + current_commit=$(git rev-parse HEAD) + # Try to find the last tag that contains the current commit + last_tag=$(git tag --contains ${current_commit} --sort=version:refname | head -n 1) + # If there is no tag that contains the current commit, + # get the latest tag sorted by semver. + if [[ -z "${last_tag}" ]]; then + last_tag=$(git tag --sort=version:refname | tail -n 1) + fi fi version="${last_tag}" From 2a4bb65054a2faf3baadd35da567780482b6558f Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Wed, 12 Jun 2024 12:44:48 -0400 Subject: [PATCH 2/2] Update version.sh Co-authored-by: Dean Sheather --- scripts/version.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/version.sh b/scripts/version.sh index ea9f168d80d8c..4a87853d2c99d 100755 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -43,7 +43,7 @@ if ! [[ ${remote_url} =~ [@/]github.com ]] && ! [[ ${remote_url} =~ [:/]coder/co else current_commit=$(git rev-parse HEAD) # Try to find the last tag that contains the current commit - last_tag=$(git tag --contains ${current_commit} --sort=version:refname | head -n 1) + last_tag=$(git tag --contains "$current_commit" --sort=version:refname | head -n 1) # If there is no tag that contains the current commit, # get the latest tag sorted by semver. if [[ -z "${last_tag}" ]]; then