.PHONY: help
# from https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n\n", $$1, $$2}'

repo=yardstick
project=measure-solver
branch=$(shell git rev-parse --abbrev-ref HEAD)
tag=$(shell echo $(branch) | grep -Eo 'feature/([A-Za-z]+-[0-9]*)' | grep -Eo '[A-Za-z]+-[0-9]*' || \
		echo $(branch) | grep -Eo '(release|hotfix)/[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' | grep -Eo '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' || \
		echo $(branch) | grep -Eo 'QUANT-([[:digit:]]*)')
full: build push


build: ## build the production dockerfile
	@if [[ -n "$(tag)" ]]; then \
		echo "$(tag)" > docker_tag.txt; \
		docker build -t $(repo)/$(project):$(tag) .; \
    else \
	    echo "Nothing to build."; \
    fi
push: ## push the production dockerfile
	@if [[ -n "$(tag)" ]]; then \
		docker push $(repo)/$(project):$(tag); \
	else \
		echo "Nothing to push."; \
    fi

display: ## display the tag/branch values for development testing
	@echo "branch: $(branch)"
	@echo "tag: $(tag)"