Reputation: 1023
Ive make file with the version that I want to increase automatically the patch value every time by one when I runmake pr
TAG = 0.0.1
pr:
docker build -t $(REGISTRY)/$(APP):$(TAG) .
I want to every time that I’ll run make pr
it will increase the number,
Its ok that only the last number will be increased
Like make pr
TAG = 0.0.2
After another 8 times
TAG = 0.0.10
Another 90
TAG = 0.0.100
Upvotes: 0
Views: 40
Reputation: 99134
You could use a shell variable instead of a Make variable:
pr:
read TAG < nnn; docker build -t $(REGISTRY)/$(APP):0.0.$$TAG; echo $$((TAG+1)) > nnn
EDIT: this assumes a file named nnn
that contains "1" initially.
Upvotes: 1
Reputation: 6994
With GNU make you can do:
TAG = 0.0.${PR}
-include .pr.mk
PR ?= 0
pr: FORCE
@echo ${TAG}
.pr.mk:
@rm -f $@
@echo "PR=$$(( ${PR} + 1 ))" > $@
FORCE:
.PHONY: FORCE .pr.mk
Upvotes: 1