[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
common: calculate major, minor and patch versions correctly by using …
Browse files Browse the repository at this point in the history
…cut command

Signed-off-by: Muvaffak Onus <me@muvaf.com>
  • Loading branch information
muvaf committed Oct 11, 2022
1 parent b2a9a2d commit 3152836
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions makelib/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,16 @@ export VERSION

VERSION_REGEX := ^v\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)$$
VERSION_VALID := $(shell echo "$(VERSION)" | grep -q '$(VERSION_REGEX)' && echo 1 || echo 0)
VERSION_MAJOR := $(shell echo "$(VERSION)" | sed -e 's/$(VERSION_REGEX)/\1/')
VERSION_MINOR := $(shell echo "$(VERSION)" | sed -e 's/$(VERSION_REGEX)/\2/')
VERSION_PATCH := $(shell echo "$(VERSION)" | sed -e 's/$(VERSION_REGEX)/\3/')

# Given "v0.17.0-3.gb4eee9f.dirty" it returns "0".
VERSION_MAJOR := $(shell echo "$(VERSION)" | cut -d'.' -f1 | sed '1s/^.//')

# Given "v0.17.0-3.gb4eee9f.dirty" it returns "17".
VERSION_MINOR := $(shell echo "$(VERSION)" | cut -d'.' -f2)

# Given "v0.17.0-3.gb4eee9f.dirty" it returns "0-3.gb4eee9f.dirty".
# Given "v0.17.1" it returns "1".
VERSION_PATCH := $(shell echo "$(VERSION)" | cut -d'.' -f3-)

release.tag:
ifneq ($(VERSION_VALID),1)
Expand Down

0 comments on commit 3152836

Please sign in to comment.