I'm trying to compare version values between the pacakge.json latest git tag so that I can fail the CI build if the versions do not match. I've created a make target that will take the two version values and do a string comparison to make sure they are the same, although I'm open to numeric comparsions if possible.
PKG_VERSION=$(shell echo v$$(jq .version package.json))
LATEST_TAG=$(shell git describe --tags --abbrev=0 $$(git rev-list --tags --max-count=1))
enforce-versions:
@echo "Comparing \"$(PKG_VERSION)\" & \"$(LATEST_TAG)\""
ifeq ($(PKG_VERSION), $(LATEST_TAG))
exit 0;
else
exit 1;
endif
Output:
$ make enforce-versions
Comparing "v1.0.0" & "v1.1.0"
exit 1;
make: *** [enforce-versions] Error 1
$ make enforce-versions
Comparing "v1.1.0" & "v1.1.0"
exit 1;
make: *** [enforce-versions] Error 1