-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (40 loc) · 1.54 KB
/
Copy pathMakefile
File metadata and controls
55 lines (40 loc) · 1.54 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
.PHONY: build build-all clean test install uninstall fmt lint tidy
BINARY=cfluence
DIST=dist
PREFIX=$(HOME)/.local
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
GIT_COMMIT=$(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
BUILD_DATE=$(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS=-ldflags "-s -w \
-X github.com/kristofferrisa/confluence-cli/internal/commands.Version=$(VERSION) \
-X github.com/kristofferrisa/confluence-cli/internal/commands.GitCommit=$(GIT_COMMIT) \
-X github.com/kristofferrisa/confluence-cli/internal/commands.BuildDate=$(BUILD_DATE)"
build:
go build $(LDFLAGS) -o $(BINARY) ./cmd/cfluence
install: build
mkdir -p $(PREFIX)/bin
cp $(BINARY) $(PREFIX)/bin/$(BINARY)
@echo "Installed $(BINARY) to $(PREFIX)/bin/$(BINARY)"
uninstall:
rm -f $(PREFIX)/bin/$(BINARY)
@echo "Removed $(PREFIX)/bin/$(BINARY)"
test:
go test -v ./...
build-all: build-linux build-darwin build-windows
build-linux:
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o $(DIST)/$(BINARY)-linux-amd64 ./cmd/cfluence
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o $(DIST)/$(BINARY)-linux-arm64 ./cmd/cfluence
build-darwin:
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o $(DIST)/$(BINARY)-darwin-amd64 ./cmd/cfluence
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o $(DIST)/$(BINARY)-darwin-arm64 ./cmd/cfluence
build-windows:
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o $(DIST)/$(BINARY)-windows-amd64.exe ./cmd/cfluence
clean:
rm -f $(BINARY)
rm -rf $(DIST)
fmt:
go fmt ./...
lint:
golangci-lint run
tidy:
go mod tidy