Skip to content

Commit d9ecc50

Browse files
Make is_not_number reusable
test patch version before adding to it
1 parent ced8056 commit d9ecc50

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ RELEASE_ROOT ?=releases
77
DEV_TEST_BUILD =./$(PROJECT)
88
TARGETS ?=linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64
99

10+
define is_not_number
11+
$(shell echo ${1} | sed -e 's/[0123456789]//g')
12+
endef
13+
1014
ifneq ($(VERSION),)
1115
VERSION_SPLIT:=$(subst ., ,$(VERSION))
1216
ifneq ($(words $(VERSION_SPLIT)),3)
@@ -18,12 +22,15 @@ VERSION_SPLIT:=$(subst ., ,$(VERSION_TAG))
1822
ifneq ($(words $(VERSION_SPLIT)),3)
1923
$(error VERSION_TAG does not have 3 parts |$(words $(VERSION_SPLIT))|$(VERSION_TAG)|$(VERSION_SPLIT)|)
2024
endif
25+
26+
ifneq ($(words $(call is_not_number,$(word 3,$(VERSION_SPLIT)))), 0)
27+
$(error The VERSION_TAG patch version string contain non-numeric characters)
28+
endif
29+
2130
VERSION_SPLIT:=$(wordlist 1, 2, $(VERSION_SPLIT)) $(shell echo $$(($(word 3,$(VERSION_SPLIT))+1)))
2231
endif
2332

24-
IS_NOT_NUMBER:=$(shell echo $(VERSION_SPLIT) | sed -e 's/[0123456789]//g')
25-
26-
ifneq ($(words $(IS_NOT_NUMBER)), 0)
33+
ifneq ($(words $(call is_not_number,$(VERSION_SPLIT))), 0)
2734
$(error The version string contain non-numeric characters)
2835
endif
2936

@@ -101,6 +108,7 @@ release-all: release-clean distbuild $(RELEASES) show-releases
101108
distbuild:
102109
@mkdir -p $(RELEASE_ROOT)
103110

111+
# Arguments os,arch,build
104112
define build-target
105113
release-$(1)/$(2)-$(PROJECT): RELEASE_GO_LDFLAGS:=-ldflags="$(GO_LDFLAGS) -X '$(GOMODULECMD).GoOs=$(1)' -X '$(GOMODULECMD).GoArch=$(2)'"
106114

0 commit comments

Comments
 (0)