-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
82 lines (64 loc) · 1.97 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
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
BUILDDATE := $(shell date +'%Y-%m-%d')
BUILDTIME := $(shell date +'%H:%M:%S')
CURPATH := ${shell pwd}
APP := devcert
APP_INPUT := .
APP_OUTPUT := /usr/local/bin/${APP}
RELEASE_OUTPUT := ./.bin/${APP}
RELEASE_WIN_AMD64_EXT := ${RELEASE_OUTPUT}_win_amd64.exe
RELEASE_DARWIN_AMD64_EXT := ${RELEASE_OUTPUT}_darwin_amd64
RELEASE_DARWIN_ARM64_EXT := ${RELEASE_OUTPUT}_darwin_arm64
RELEASE_LINUX_AMD64_EXT := ${RELEASE_OUTPUT}_linux_amd64
RELEASE_LINUX_ARM64_EXT := ${RELEASE_OUTPUT}_linux_arm64
.PHONY: clean format release
update-deps:
go mod tidy
go get -u ./...
clean:
go clean ${APP_INPUT}
format:
gofmt -w ${CURPATH}
build:
go build \
-ldflags "-X main.BuildDate=$(BUILDDATE) -X main.BuildTime=$(BUILDTIME)" \
-o $(APP_OUTPUT) \
$(APP_INPUT)
release-win-amd64:
env GOOS=windows GOARCH=amd64 \
go build \
-ldflags "-X main.BuildDate=$(BUILDDATE) -X main.BuildTime=$(BUILDTIME)" \
-o $(RELEASE_WIN_AMD64_EXT) \
$(APP_INPUT)
release-darwin-amd64:
env GOOS=darwin GOARCH=amd64 \
go build \
-ldflags "-X main.BuildDate=$(BUILDDATE) -X main.BuildTime=$(BUILDTIME)" \
-o $(RELEASE_DARWIN_AMD64_EXT) \
$(APP_INPUT)
release-darwin-arm64:
env GOOS=darwin GOARCH=arm64 \
go build \
-ldflags "-X main.BuildDate=$(BUILDDATE) -X main.BuildTime=$(BUILDTIME)" \
-o $(RELEASE_DARWIN_ARM64_EXT) \
$(APP_INPUT)
release-linux-amd64:
env GOOS=linux GOARCH=amd64 \
go build \
-ldflags "-X main.BuildDate=$(BUILDDATE) -X main.BuildTime=$(BUILDTIME)" \
-o $(RELEASE_LINUX_AMD64_EXT) \
$(APP_INPUT)
release-linux-arm64:
env GOOS=linux GOARCH=arm64 \
go build \
-ldflags "-X main.BuildDate=$(BUILDDATE) -X main.BuildTime=$(BUILDTIME)" \
-o $(RELEASE_LINUX_ARM64_EXT) \
$(APP_INPUT)
compile-releases: release-win-amd64 release-darwin-amd64 release-darwin-arm64 release-linux-amd64 release-linux-arm64
echo "Compiled releases"
exec: clean format build
${APP_OUTPUT}