-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
73 lines (59 loc) · 2.27 KB
/
Makefile
File metadata and controls
73 lines (59 loc) · 2.27 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
GO ?= go
BINARY := tmux-popup-control
GOCACHE := $(CURDIR)/.gocache
GOMODCACHE := $(CURDIR)/.gomodcache
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS := -ldflags="-X main.Version=$(VERSION)"
GO_ENV := GOTMUXCC_TRACE=1 GOTMUXCC_TRACE_FILE=$(CURDIR)/gotmuxcc_trace.log GOCACHE=$(GOCACHE) GOMODCACHE=$(GOMODCACHE) GOFLAGS=-modcacherw GOPROXY=off
.SILENT:
.PHONY: build run tidy fmt test clean-cache ensure-dirs cover update-gotmuxcc release
ensure-dirs:
mkdir -p $(GOCACHE) $(GOMODCACHE)
build: ensure-dirs
$(GO_ENV) go build $(LDFLAGS) -o $(BINARY) .
run: ensure-dirs
$(GO_ENV) go run .
fmt:
$(GO_ENV) gofmt -w .
tidy: ensure-dirs
$(GO_ENV) go mod tidy
test: ensure-dirs
$(GO_ENV) go test ./...
GO_ENV_ONLINE := GOCACHE=$(GOCACHE) GOMODCACHE=$(GOMODCACHE) GOFLAGS=-modcacherw GOPROXY=direct
update-gotmuxcc: ensure-dirs
$(GO_ENV_ONLINE) go get github.com/atomicstack/gotmuxcc@latest
$(GO_ENV_ONLINE) go mod tidy
$(GO_ENV_ONLINE) go mod vendor
clean-cache:
rm -rf $(GOCACHE) $(GOMODCACHE)
cover:
@echo "==> Generating coverage report"
$(GO) test ./... -coverprofile=coverage.out
@echo "Coverage summary:"
$(GO) tool cover -func=coverage.out
RELEASE_DIR := dist
PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64
RELEASE_SUPPORT_FILES := README.md main.sh main.tmux
release: ensure-dirs
rm -rf $(RELEASE_DIR)
mkdir -p $(RELEASE_DIR)
$(foreach platform,$(PLATFORMS),\
$(eval GOOS := $(word 1,$(subst /, ,$(platform))))\
$(eval GOARCH := $(word 2,$(subst /, ,$(platform))))\
echo "Building $(GOOS)/$(GOARCH)..." && \
$(GO_ENV) GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 \
go build $(LDFLAGS) -o $(RELEASE_DIR)/$(BINARY)-$(GOOS)-$(GOARCH) . && \
) true
chmod +x $(RELEASE_DIR)/$(BINARY)-*
cd $(RELEASE_DIR) && for f in $(BINARY)-*; do \
stage_dir="$$(mktemp -d ./release.XXXXXX)"; \
cp "$$f" "$$stage_dir/$(BINARY)"; \
cp $(addprefix ../,$(RELEASE_SUPPORT_FILES)) "$$stage_dir/"; \
chmod +x "$$stage_dir/$(BINARY)" "$$stage_dir/main.sh" "$$stage_dir/main.tmux"; \
COPYFILE_DISABLE=1 tar czf "$$f.tar.gz" -C "$$stage_dir" .; \
rm -rf "$$stage_dir" "$$f"; \
done
cd $(RELEASE_DIR) && shasum -a 256 *.tar.gz > checksums.txt
gh release create v$(VERSION) $(RELEASE_DIR)/* \
--title "v$(VERSION)" \
--generate-notes