-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
37 lines (29 loc) · 1 KB
/
Makefile
File metadata and controls
37 lines (29 loc) · 1 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
VERSION := $(shell cat VERSION)
BINARY = srcutil
PLATFORMS = darwin/amd64 darwin/arm64 linux/amd64 linux/arm64
OUTPUT_DIR = dist
.PHONY: all build clean install uninstall release gh-release
all: build
build:
mkdir -p $(OUTPUT_DIR)
go build -ldflags "-X main.version=$(VERSION)" -o $(OUTPUT_DIR)/$(BINARY) ./main.go
clean:
rm -rf $(OUTPUT_DIR)
install: build
mv $(OUTPUT_DIR)/$(BINARY) /usr/local/bin/$(BINARY)
uninstall:
rm -f /usr/local/bin/$(BINARY)
release: clean
mkdir -p $(OUTPUT_DIR)
$(foreach PLATFORM, $(PLATFORMS), \
$(eval OS = $(word 1,$(subst /, ,$(PLATFORM)))) \
$(eval ARCH = $(word 2,$(subst /, ,$(PLATFORM)))) \
GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags "-X main.version=$(VERSION)" -o $(OUTPUT_DIR)/$(BINARY)-$(VERSION)-$(OS)-$(ARCH) ./main.go; \
)
tar czf $(BINARY)-$(VERSION).tar.gz --exclude=.git --exclude=$(OUTPUT_DIR) .
gh-release: release
gh release create "v$(VERSION)" \
--title "v$(VERSION)" \
--notes "Release v$(VERSION)" \
./dist/* \
./srcutil-$(VERSION).tar.gz