Skip to content

Commit be270a6

Browse files
committed
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.
1 parent 67934fe commit be270a6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

script/release

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
# Variables
2222
tag_regex='v[0-9]+\.[0-9]+\.[0-9]+$'
23+
tag_glob='v[0-9].[0-9].[0-9]*'
2324

2425
# Terminal colors
2526
OFF='\033[0m'
@@ -28,7 +29,7 @@ GREEN='\033[0;32m'
2829
BLUE='\033[0;34m'
2930

3031
# Get the latest release tag
31-
latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
32+
latest_tag=$(git describe --abbrev=0 --match="$tag_glob")
3233

3334
if [[ -z "$latest_tag" ]]; then
3435
# There are no existing release tags

0 commit comments

Comments
 (0)