forked from pouriyajamshidi/tcping
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (56 loc) · 1.89 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
EXEC_DIR = executables/
SOURCE_FILES = $(tcping.go statsprinter.go)
.PHONY: all build update clean format test vet gitHubActions container
all: build
check: format vet test
build: clean update format vet test
@mkdir -p $(EXEC_DIR)
@echo "[+] Building the Linux version"
@go build -ldflags "-s -w" -o $(EXEC_DIR)tcping $(SOURCE_FILES)
@echo "[+] Packaging the Linux version"
@zip -j $(EXEC_DIR)tcping_Linux.zip $(EXEC_DIR)tcping > /dev/null
@echo "[+] Removing the Linux binary"
@rm $(EXEC_DIR)tcping
@echo
@echo "[+] Building the Windows version"
@env GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o $(EXEC_DIR)tcping.exe $(SOURCE_FILES)
@echo "[+] Packaging the Windows version"
@zip -j $(EXEC_DIR)tcping_Windows.zip $(EXEC_DIR)tcping.exe > /dev/null
@echo "[+] Removing the Windows binary"
@rm $(EXEC_DIR)tcping.exe
@echo
@echo "[+] Building the MacOS version"
@env GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w" -o $(EXEC_DIR)tcping $(SOURCE_FILES)
@echo "[+] Packaging the MacOS version"
@zip -j $(EXEC_DIR)tcping_MacOS.zip $(EXEC_DIR)tcping > /dev/null
@echo "[+] Removing the MacOS binary"
@rm $(EXEC_DIR)tcping
@echo "[+] Done"
update:
@echo "[+] Updating Go dependencies"
@go get -u
@echo "[+] Done"
clean:
@echo "[+] Cleaning files"
@rm -rf $(EXEC_DIR)
@echo "[+] Done"
@echo
format:
@echo "[+] Formatting files"
@gofmt -w *.go
vet:
@echo "[+] Running Go vet"
@go vet
test:
@echo "[+] Running tests"
@go test
container:
@echo "[+] Building container image"
@env GOOS=linux CGO_ENABLED=0 go build --ldflags '-s -w -extldflags "-static"' -o $(EXEC_DIR)tcpingDocker $(SOURCE_FILES)
@docker build -t tcping:latest .
@rm $(EXEC_DIR)tcpingDocker
@echo "[+] Done"
gitHubActions:
@echo "[+] Building container image - GitHub Actions"
@env GOOS=linux CGO_ENABLED=0 go build --ldflags '-s -w -extldflags "-static"' -o tcpingDocker $(SOURCE_FILES)
@echo "[+] Done"