Skip to content

Commit

Permalink
create makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
knbr13 committed Dec 11, 2023
1 parent c011672 commit c83bb3b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c83bb3b

Please sign in to comment.