From 89edf94cee45ac6002b1e8a17e2c074b07f7bae0 Mon Sep 17 00:00:00 2001 From: Bernhard Reiter Date: Wed, 1 Jun 2022 09:56:37 +0200 Subject: [PATCH] Improve Makefile to better set version number * Add --always to git describe to also return if we are run on a shallow clone in a git hub action with action/checkout. --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7b0c608..2d0edc8 100644 --- a/Makefile +++ b/Makefile @@ -42,8 +42,9 @@ tag_checked_out: # any commit after a tag is considered newer than the semver from the tag # without an optional 'v' # Note we need `--tags` because github release only creates lightweight tags -# (see feature request https://github.com/github/feedback/discussions/4924) -GITDESC := $(shell git describe --tags) +# (see feature request https://github.com/github/feedback/discussions/4924). +# We use `--always` in case of being run as github action with shallow clone. +GITDESC := $(shell git describe --tags --always) 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 (`-`)