Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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.
  • Loading branch information
EliahKagan committed Sep 13, 2023
commit b1c61d933d36a8e7fb6fb4109d2b07bd06bfbf32
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ clean:

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

make force_release

force_release: clean
Expand Down