From 3bff74e02ff12b3451194961757a3bc6c8a3afbb Mon Sep 17 00:00:00 2001 From: Hailey Date: Sat, 06 Dec 2025 01:30:27 +0000 Subject: [PATCH] add release to makefile --- .gitignore | 1 + Makefile | 38 +++++++++++++++++++++++++++++++++++++- 2 file(s) changed, 38 insertion(s)(+), 1 deletion(s)(-) diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ *.secret .DS_Store data/ keys/ +dist/ diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -4,6 +4,23 @@ GIT_TAG := $(shell git describe --tags --exact-match 2>/dev/null) GIT_COMMIT := $(shell git rev-parse --short=9 HEAD) VERSION := $(if $(GIT_TAG),$(GIT_TAG),dev-$(GIT_COMMIT)) +# Build output directory +BUILD_DIR := dist + +# Platforms to build for +PLATFORMS := \ + linux/amd64 \ + linux/arm64 \ + linux/arm \ + darwin/amd64 \ + darwin/arm64 \ + windows/amd64 \ + windows/arm64 \ + freebsd/amd64 \ + freebsd/arm64 \ + openbsd/amd64 \ + openbsd/arm64 + .PHONY: help help: ## Print info about all commands @echo "Commands:" @@ -14,6 +31,25 @@ .PHONY: build build: ## Build all executables go build -ldflags "-X main.Version=$(VERSION)" -o cocoon ./cmd/cocoon +.PHONY: build-release +build-all: ## Build binaries for all architectures + @echo "Building for all architectures..." + @mkdir -p $(BUILD_DIR) + @$(foreach platform,$(PLATFORMS), \ + $(eval OS := $(word 1,$(subst /, ,$(platform)))) \ + $(eval ARCH := $(word 2,$(subst /, ,$(platform)))) \ + $(eval EXT := $(if $(filter windows,$(OS)),.exe,)) \ + $(eval OUTPUT := $(BUILD_DIR)/cocoon-$(VERSION)-$(OS)-$(ARCH)$(EXT)) \ + echo "Building $(OS)/$(ARCH)..."; \ + GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags "-X main.Version=$(VERSION)" -o $(OUTPUT) ./cmd/cocoon && \ + echo " ✓ $(OUTPUT)" || echo " ✗ Failed: $(OS)/$(ARCH)"; \ + ) + @echo "Done! Binaries are in $(BUILD_DIR)/" + +.PHONY: clean-dist +clean-dist: ## Remove all built binaries + rm -rf $(BUILD_DIR) + .PHONY: run run: go build -ldflags "-X main.Version=dev-local" -o cocoon ./cmd/cocoon && ./cocoon run @@ -43,4 +79,4 @@ if [ ! -f ".env" ]; then cp example.dev.env .env; fi .PHONY: docker-build docker-build: - docker build -t cocoon . \ No newline at end of file + docker build -t cocoon . -- tangled.sh