.PHONY: all build push

VERSION := $(shell date +%Y-%m-%dT%H.%M)
STAGE=kirby-test

all: push cleanup

build:
	ya package pkg.json --docker --docker-repository=security --custom-version=$(VERSION)

push:
	ya package pkg.json --docker --docker-repository=security --custom-version=$(VERSION) --docker-push
	@echo
	@echo "Image uploaded: registry.yandex.net/security/kirby:$(VERSION)"


deploy: TARGET_REV = $(shell ya tool yp get stage "$(STAGE)" /spec/revision --address xdc --format json  | ya tool jq '(.[0] + 1)') 
deploy: push
	ya tool yp update stage "$(STAGE)" --set /spec/revision "$(TARGET_REV)" --set /spec/deploy_units/du/images_for_boxes/api/tag '"'"$(VERSION)"'"' --address xdc
	@echo
	@echo "Stage updated"

cleanup:
	rm -rf packages.json
	rm -rf *.tar.gz
