-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
91 lines (71 loc) · 1.88 KB
/
Makefile
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
export VERSION = ${shell git describe --tags 2>/dev/null}
export SOURCE_DATE_ISO = ${shell TZ=UTC git log ${VERSION} -1 --date=iso-local --pretty=%cd}
BIN = apisocks5
GO_LDFLAGS = -buildid= -s -w -X main.VERSION=${VERSION}
.PHONY: all
all: ${BIN}
.PHONY: ${BIN}
${BIN}:
go build -a -trimpath -buildvcs=false -ldflags "${GO_LDFLAGS}" -o ${BIN} .
.PHONY: install
install:
go install
.PHONY: clean
clean:
rm -f ${BIN} ${BIN}.exe ${BIN}*.zip ${BIN}*.asc
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: vet
vet:
golangci-lint run ./...
.PHONY: vuln
vuln:
govulncheck ./...
.PHONY: test
test:
go test -v ./...
.PHONY: ci
ci:
podman build --quiet --target test -t ${BIN}-tester .
podman run --rm -v .:/build:Z -w /build \
-it ${BIN}-tester make all vuln test vet
.PHONY: build-container
build-container:
podman build --target build -t ${BIN} .
.PHONY: build
build: build-container
podman run --rm -v .:/build:Z -w /build \
-e GOOS=${GOOS} -e GOARCH=${GOARCH} -e TZ=UTC \
${BIN} \
sh -c '\
make BIN=${BIN}${EXT} && \
touch -d "${SOURCE_DATE_ISO}" ${BIN}${EXT} && \
zip -X ${BIN}_${VERSION}_${GOOS}_${GOARCH}.zip ${BIN}${EXT}'
.PHONY: release-darwin-amd64
release-darwin-amd64:
$(MAKE) GOOS=darwin GOARCH=amd64 build
.PHONY: release-darwin-arm64
release-darwin-arm64:
$(MAKE) GOOS=darwin GOARCH=arm64 build
.PHONY: release-linux-amd64
release-linux-amd64:
$(MAKE) GOOS=linux GOARCH=amd64 build
.PHONY: release-linux-arm64
release-linux-arm64:
$(MAKE) GOOS=linux GOARCH=arm64 build
.PHONY: release-windows-amd64
release-windows-amd64:
$(MAKE) GOOS=windows GOARCH=amd64 EXT=.exe build
.PHONY: release-windows-arm64
release-windows-arm64:
$(MAKE) GOOS=windows GOARCH=arm64 EXT=.exe build
.PHONY: release
release: \
clean \
release-darwin-amd64 \
release-darwin-arm64 \
release-linux-amd64 \
release-linux-arm64 \
release-windows-amd64 \
release-windows-arm64