-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
50 lines (40 loc) · 1.35 KB
/
Makefile
File metadata and controls
50 lines (40 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
NAME = git-syncer
VERSION ?= $(shell echo "v1.0.1-release_build.")$(shell git rev-parse --short HEAD)
OS = linux darwin
architecture = amd64 arm64
.DEFAULT_GOAL := help
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-16s\033[0m %s\n", $$1, $$2}'
build: deps ## Build the project
go build -ldflags "-s -w -X 'main.version=$(VERSION)'"
all: release release-windows ## Generate releases for all supported systems
release: clean deps ## Generate releases for unix systems
@for arch in $(architecture);\
do \
for os in ${OS};\
do \
echo "Building $$os-$$arch"; \
mkdir -p build; \
GOOS=$$os GOARCH=$$arch go build -ldflags "-s -w -X 'main.version=$(VERSION)'" -o build/$(NAME)-$$os-$$arch; \
upx -9 build/$(NAME)-$$os-$$arch; \
done \
done
release-windows: clean deps ## Generate releases for unix systems
@for arch in $(architecture);\
do \
for os in windows;\
do \
echo "Building $$os-$$arch"; \
mkdir -p build; \
GOOS=$$os GOARCH=$$arch go build -ldflags "-s -w -X 'main.version=$(VERSION)'" -o build/$(NAME)-$$os-$$arch.exe; \
upx -9 build/$(NAME)-$$os-$$arch.exe; \
done \
done
test: deps ## Execute tests
go test ./...
deps: ## Install dependencies using go get
go get -d -v -t ./...
clean: ## Remove building artifacts
rm -rf build
rm -f $(NAME)