VERSION ?= 2.7
GIT_BRANCH = $(shell git symbolic-ref --short HEAD)
TARGET ?= $(GIT_BRANCH)-candidate 
COMPONENT = 3scale-toolbox
TAG ?= $(shell cut -f 2 -d ' ' source-repos)

.DEFAULT_GOAL := help
.PHONY : help
help: Makefile
	@sed -n 's/^##//p' $<

## info: Build configuration info
.PHONY: info
info:
	@echo "************************************************************"
	@echo This Makefile builds $(COMPONENT)
	@echo BRANCH=$(GIT_BRANCH) TARGET=$(TARGET)
	@echo "************************************************************"
	@echo
	@echo Please check this matches your expectations and override variables if needed.
	@echo

$(COMPONENT)-$(TAG).tar.gz:
	rhpkg sources

build: $(COMPONENT)-$(TAG).tar.gz
	docker build -t $(COMPONENT):$(TAG) .

## test: brew scratch-build
.PHONY: test
test:
	rhpkg container-build --scratch --target=$(TARGET)

## brew: brew build
.PHONY: brew
brew:
ifneq (,$(findstring private-,$(GIT_BRANCH)))
	$(error can't build from private branch $(GIT_BRANCH))
else
	rhpkg container-build --target=$(TARGET)
endif

smoke:
	echo "TODO..."
