1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 18:15:42 +01:00

improve Makefile improvement

This commit is contained in:
Bernhard Reiter 2024-11-15 12:12:24 +01:00 committed by Paul Schwabauer
parent ace8aeaf98
commit 1e3504c753

View file

@ -41,19 +41,19 @@ tag_checked_out:
# into a semver version. For this we increase the PATCH number, so that # into a semver version. For this we increase the PATCH number, so that
# any commit after a tag is considered newer than the semver from the tag # any commit after a tag is considered newer than the semver from the tag
# without an optional 'v' # without an optional 'v'
# Note we need `--tags` because github release only creates lightweight tags # Note we need `--tags` because github releases only create lightweight tags
# (see feature request https://github.com/github/feedback/discussions/4924). # (see feature request https://github.com/github/feedback/discussions/4924).
# We use `--always` in case of being run as github action with shallow clone. # We use `--always` in case of being run as github action with shallow clone.
# In this case we might in some situations see an error like # In this case we might in some situations see an error like
# `/bin/bash: line 1: 2b55bbb: value too great for base (error token is "2b55bbb")` # `/bin/bash: line 1: 2b55bbb: value too great for base (error token is "2b55bbb")`
# which can be ignored. # which can be ignored.
GITDESC := $(shell git describe --tags --always | sed -E 's/^v//') GITDESC := $(shell git describe --tags --always)
GITDESCPATCH := $(shell echo '$(GITDESC)' | sed -E 's/[0-9]+\.[0-9]+\.([0-9]+)[-+]?.*/\1/') GITDESCPATCH := $(shell echo '$(GITDESC)' | sed -E 's/v?[0-9]+\.[0-9]+\.([0-9]+)[-+]?.*/\1/')
SEMVERPATCH := $(shell echo $$(( $(GITDESCPATCH) + 1 ))) SEMVERPATCH := $(shell echo $$(( $(GITDESCPATCH) + 1 )))
# Hint: The regexp in the next line only matches if there is a hyphen (`-`) # Hint: The second regexp in the next line only matches
# followed by a number, by which we assume that git describe # if there is a hyphen (`-`) followed by a number,
# has added a string after the tag # by which we assume that git describe has added a string after the tag
SEMVER := $(shell echo '$(GITDESC)' | sed -E 's/([0-9]+\.[0-9]+\.)([0-9]+)(-[1-9].*)/\1$(SEMVERPATCH)\3/' ) SEMVER := $(shell echo '$(GITDESC)' | sed -E -e 's/^v//' -e 's/([0-9]+\.[0-9]+\.)([0-9]+)(-[1-9].*)/\1$(SEMVERPATCH)\3/' )
testsemver: testsemver:
@echo from \'$(GITDESC)\' transformed to \'$(SEMVER)\' @echo from \'$(GITDESC)\' transformed to \'$(SEMVER)\'