From d8d6eb3f436bae51a873e4b9d422c5b6eee3035c Mon Sep 17 00:00:00 2001 From: Bernhard Reiter Date: Wed, 11 May 2022 10:42:39 +0200 Subject: [PATCH] Improve Makefile for release version numbers * Improve the pattern to leave tagged release version numbers like `0.2.2-alpha` alone and only increase version numbers where git describe has added a string starting with a number. --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index acbe145..0f23e23 100644 --- a/Makefile +++ b/Makefile @@ -45,8 +45,9 @@ GITDESC := $(shell git describe) GITDESCPATCH := $(shell echo '$(GITDESC)' | sed -E 's/v?[0-9]+\.[0-9]+\.([0-9]+)[-+]?.*/\1/') SEMVERPATCH := $(shell echo $$(( $(GITDESCPATCH) + 1 ))) # Hint: The regexp in the next line only matches if there is a hyphen (`-`) -# and we can assume that git describe has added a string after the tag -SEMVER := $(shell echo '$(GITDESC)' | sed -E 's/v?([0-9]+\.[0-9]+\.)([0-9]+)(-.*)/\1$(SEMVERPATCH)\3/' ) +# followed by a number, by which we assume that git describe +# has added a string after the tag +SEMVER := $(shell echo '$(GITDESC)' | sed -E 's/v?([0-9]+\.[0-9]+\.)([0-9]+)(-[1-9].*)/\1$(SEMVERPATCH)\3/' ) testsemver: @echo from \'$(GITDESC)\' transformed to \'$(SEMVER)\'