VERSION := $(shell grep 'version:' pubspec.yaml | sed 's/version: //')
MAJOR := $(shell echo $(VERSION) | cut -d. -f1)
MAJOR_MINOR := $(shell echo $(VERSION) | cut -d. -f1,2)

build:
	dart run build_runner build --delete-conflicting-outputs

watch:
	dart run build_runner watch --delete-conflicting-outputs

docker: build
	docker build \
		-t cr.mars3142.io/model-railway/cinema-display:latest \
		-t cr.mars3142.io/model-railway/cinema-display:$(MAJOR) \
		-t cr.mars3142.io/model-railway/cinema-display:$(MAJOR_MINOR) \
		-t cr.mars3142.io/model-railway/cinema-display:$(VERSION) \
		.

multi: build
	docker buildx build \
		--platform linux/amd64,linux/arm64 \
		-t cr.mars3142.io/model-railway/cinema-display:latest \
		-t cr.mars3142.io/model-railway/cinema-display:$(MAJOR) \
		-t cr.mars3142.io/model-railway/cinema-display:$(MAJOR_MINOR) \
		-t cr.mars3142.io/model-railway/cinema-display:$(VERSION) \
		.
