CMD_NAME := ambient-local-exporter .PHONY: all test build docker install clean VERSION ?= development # Default to "development" if VERSION is not set PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 OUTPUT_DIR := bin VER_PKG := gitea.libretechconsulting.com/rmcguire/go-app/pkg/config.Version DOCKER_IMG := gitea.libretechconsulting.com/rmcguire/ambient-local-exporter all: test build docker test: go test -v ./... build: test @echo "Building for platforms: $(PLATFORMS)" @for platform in $(PLATFORMS); do \ OS=$$(echo $$platform | cut -d/ -f1); \ ARCH=$$(echo $$platform | cut -d/ -f2); \ OUTPUT="$(OUTPUT_DIR)/$(CMD_NAME)-$$OS-$$ARCH"; \ GOOS=$$OS GOARCH=$$ARCH go build -ldflags "-X $(VER_PKG)=$(VERSION)" -o $$OUTPUT; \ echo "Built $$OUTPUT"; \ done go build -ldflags "-X $(VER_PKG)=$(VERSION)" -o bin/${CMD_NAME} docker: @echo "Building Docker image $(DOCKER_IMG):$(VERSION)" docker build \ --build-arg VER_PKG=$(VER_PKG) \ --build-arg VERSION=$(VERSION) \ -t $(DOCKER_IMG):$(VERSION) . docker push $(DOCKER_IMG):$(VERSION) install: go install -v -ldflags "-X $(VER_PKG)=$(VERSION)" . clean: rm -rf bin/${CMD_NAME}