-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
94 lines (80 loc) Β· 2.53 KB
/
Copy pathMakefile
File metadata and controls
94 lines (80 loc) Β· 2.53 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
BINARY := pgflow
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -ldflags="-s -w -X main.version=$(VERSION)"
INSTALL_DIR ?= $(HOME)/.local/bin
DIST_DIR := dist
# NOTE: `install` / `uninstall` need GNU/BSD install(1). On Windows, use
# install.ps1 / uninstall.ps1 instead.
#
# Supported platforms for releases
PLATFORMS := \
darwin/amd64 \
darwin/arm64 \
linux/amd64 \
linux/arm64 \
windows/amd64 \
windows/arm64
.PHONY: all build run test vet tidy install uninstall clean release build-all help
all: test build
## help: show this help
help:
@echo "pgflow β make targets:"
@echo " all test + build"
@echo " build build the binary for the current platform"
@echo " run build and launch the TUI"
@echo " test run the test suite"
@echo " vet static analysis"
@echo " tidy go mod tidy"
@echo " install install to \$$INSTALL_DIR"
@echo " uninstall remove from \$$INSTALL_DIR"
@echo " clean remove build artifacts"
@echo " build-all cross-compile for all supported platforms β dist/ (+ checksums.txt)"
@echo " release alias for build-all"
## build: build the binary for the current platform
build:
go build $(LDFLAGS) -o $(BINARY) .
## run: build and launch the TUI
run: build
./$(BINARY)
## test: run the test suite
test:
go test ./...
## vet: go vet
vet:
go vet ./...
## tidy: clean up go.mod / go.sum
tidy:
go mod tidy
## install: build + copy binary to INSTALL_DIR
install: build
install -d $(INSTALL_DIR)
install -m 0755 $(BINARY) $(INSTALL_DIR)/$(BINARY)
@echo "β
installed β $(INSTALL_DIR)/$(BINARY)"
## uninstall: remove binary from INSTALL_DIR
uninstall:
rm -f $(INSTALL_DIR)/$(BINARY)
## clean: remove build artifacts
clean:
rm -f $(BINARY)
rm -rf $(DIST_DIR)
go clean
## build-all: cross-compile for all supported platforms
build-all: clean
@mkdir -p $(DIST_DIR)
@for p in $(PLATFORMS); do \
os=$$(echo $$p | cut -d/ -f1); \
arch=$$(echo $$p | cut -d/ -f2); \
ext=""; \
if [ "$$os" = "windows" ]; then ext=".exe"; fi; \
out=$(DIST_DIR)/$(BINARY)-$$os-$$arch$$ext; \
echo " β $$out"; \
GOOS=$$os GOARCH=$$arch go build $(LDFLAGS) -o $$out . ; \
done
@cd $(DIST_DIR) && sha256sum $(BINARY)-* > checksums.txt
@echo " β $(DIST_DIR)/checksums.txt"
@ls -lh $(DIST_DIR)
## release: build all targets + generate checksums.txt in dist/
release: build-all
@echo ""
@echo "Listo. Sube con:"
@echo " gh release create vX.Y.Z dist/* --title vX.Y.Z --generate-notes"