From c83bb3b20f1b2ea5d7beef6290d5a09644898ff3 Mon Sep 17 00:00:00 2001 From: abdullah-alaadine Date: Mon, 11 Dec 2023 07:53:32 +0200 Subject: [PATCH] create makefile --- makefile | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 makefile diff --git a/makefile b/makefile new file mode 100644 index 0000000..a52a51c --- /dev/null +++ b/makefile @@ -0,0 +1,34 @@ +# Makefile for building Go tool for different platforms and compressing binaries + +# Binary name +BINARY_NAME=git-commits-vis + +# Output directory +OUTPUT_DIR=bin + +# Cross-compilation targets +PLATFORMS=linux/amd64 linux/386 windows/amd64 windows/386 darwin/amd64 + +# Build command for each platform +build: + @for platform in $(PLATFORMS); do \ + export GOOS=$${platform%/*}; \ + export GOARCH=$${platform#*/}; \ + output_name=$(OUTPUT_DIR)/$(BINARY_NAME)_$${GOOS}_$${GOARCH}; \ + if [ $$GOOS = "windows" ]; then output_name=$$output_name.exe; fi; \ + echo "Building $$output_name"; \ + go build -o $$output_name; \ + done + +# Compress binaries into a zip file +compress: + zip -j $(OUTPUT_DIR)/$(BINARY_NAME)_binaries.zip $(OUTPUT_DIR)/* + +# Clean the binaries and zip file +clean: + rm -rf $(OUTPUT_DIR)/* + +# Build and compress +all: clean build compress + +.PHONY: build compress clean all