Skip to content

Commit b1c61d9

Browse files
committed
Make "git tag" sort our SemVer-ish tags correctly
This sorts numerically for each of major, minor, and patch, rather than, e.g., rating 2.1.15 as a higher version than 2.1.2. It also rates things like X-beta and X-rc as lower versions than X, but X-patched (not SemVer, but present in this project) as higher versions than X.
1 parent 335d03b commit b1c61d9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

‎Makefile‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ clean:
88

99
release: clean
1010
# Check if latest tag is the current head we're releasing
11-
echo"Latest tag = $$(git tag -l '[0-9]*' --sort=-v:refname | head -n1)"
12-
echo"HEAD SHA = $$(git rev-parse HEAD)"
13-
echo"Latest tag SHA = $$(git tag -l '[0-9]*' --sort=-v:refname | head -n1 | xargs git rev-parse)"
14-
@test "$$(git rev-parse HEAD)" = "$$(git tag -l '[0-9]*' --sort=-v:refname | head -n1 | xargs git rev-parse)"
11+
@config_opts="$$(printf ' -c versionsort.suffix=-%s' alpha beta pre rc RC)"&&\
12+
latest_tag=$$(git $$config_opts tag -l '[0-9]*' --sort=-v:refname | head -n1)&&\
13+
head_sha=$$(git rev-parse HEAD) latest_tag_sha=$$(git rev-parse "$$latest_tag")&&\
14+
printf'%-14s = %s\n''Latest tag'"$$latest_tag"\
15+
'HEAD SHA'"$$head_sha"\
16+
'Latest tag SHA'"$$latest_tag_sha"&&\
17+
test"$$head_sha" = "$$latest_tag_sha"
18+
1519
make force_release
1620

1721
force_release: clean

0 commit comments

Comments
(0)