So I have written a Makefile that has a release function that can be run like: make release bump=patch and I want it to be fully executable in the Makefile. The only issue with my current implementation is that there is a lot of redundancy and long lines of commands, which I think can be simplified a lot, although I haven't found any better solutions yet (mainly because of the incrementation). It then tags and pushes.
The required functionality is being able to pass in patch,minor,major and have it overwrite the current file with the new version commit that and push the new tag.
It just has that 'gross' feeling, which I strive to avoid.
My current makefile looks like:
release:
$(eval v := $(shell git describe --tags --abbrev=0 | sed -E -e 's/^v//' -e 's/(.*)-.*/\1/'))
ifeq ($(bump),patch)
@echo "$v" | grep -Eo '[0-9]+$$' | tail -n 1 | awk '{print $$1 + 1}' | xargs -I '{}' sed -i '' -E 's/([0-9]+"$$)/{}"/' ._version_.py
else ifeq ($(bump),minor)
@echo "$v" | grep -Eo '(\.[0-9]+\.)' | awk '{print $$1 + 1}' | xargs -I{} sed -i '' -E 's/(\.[0-9]+\.)/.{}./' ._version_.py
else ifeq ($(bump),major)
@echo "$v" | grep -Eo '([0-9]+)' | head -n 1 | awk '{print $$1 + 1}' | xargs -I{} sed -i '' -E 's/([0-9]+)/{}/' ._version_.py
endif
$(eval a := $(shell grep -Eo '([0-9]+\.[0-9]+\.[0-9]+)' ._version_.py))
@git tag "$a"
@git commit -am "Bumped to version $a"
@git push --tags