From be270a6def94a1d39045a7782de3940e2e831b51 Mon Sep 17 00:00:00 2001 From: Paul Ebose Date: Mon, 1 Jul 2024 02:37:14 +0100 Subject: [PATCH] improve the git describe command - When using the [action versioning recommendations](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#recommendations), a commit can have duplicate tags (v2, v2.1.2). - The previous implementation did not take that into consideration. - With this new implementation, v2.1.2 is returned even when v2 is the newer commit tag (which is usually the case). - Also, when running this script from another branch (let's say 'releases/v1'), the previous implementation would return newer tags in other branches. - NOTE: This new implementation only searches for annotated tags. --- script/release | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/script/release b/script/release index aa883e2..81242a2 100755 --- a/script/release +++ b/script/release @@ -20,6 +20,7 @@ # Variables tag_regex='v[0-9]+\.[0-9]+\.[0-9]+$' +tag_glob='v[0-9].[0-9].[0-9]*' # Terminal colors OFF='\033[0m' @@ -28,7 +29,7 @@ GREEN='\033[0;32m' BLUE='\033[0;34m' # Get the latest release tag -latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)") +latest_tag=$(git describe --abbrev=0 --match="$tag_glob") if [[ -z "$latest_tag" ]]; then # There are no existing release tags