-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
36 lines (27 loc) · 989 Bytes
/
Copy pathMakefile
File metadata and controls
36 lines (27 loc) · 989 Bytes
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
.PHONY: build clean install test fmt vet
BINARY_NAME=nexus-cli
VERSION?=dev
GIT_COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS=-ldflags "-X github.com/alauda/nexus-cli/cmd.Version=$(VERSION) -X github.com/alauda/nexus-cli/cmd.GitCommit=$(GIT_COMMIT) -X github.com/alauda/nexus-cli/cmd.BuildDate=$(BUILD_DATE)"
build:
go build $(LDFLAGS) -o $(BINARY_NAME) main.go
clean:
go clean
rm -f $(BINARY_NAME)
install:
go install $(LDFLAGS)
test:
go test -v ./...
fmt:
go fmt ./...
vet:
go vet ./...
run:
go run main.go
# Build for multiple platforms
build-all:
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o $(BINARY_NAME)-linux-amd64 main.go
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o $(BINARY_NAME)-linux-arm64 main.go
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o $(BINARY_NAME)-darwin-amd64 main.go
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o $(BINARY_NAME)-darwin-arm64 main.go