-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
62 lines (46 loc) · 1.2 KB
/
Makefile
File metadata and controls
62 lines (46 loc) · 1.2 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
56
57
58
59
60
61
62
export GO111MODULE=on
SHELL := /bin/bash
NAME = osctrld
CODE_DIR = cmd/${NAME}
CODE = *.go
DEST ?= /usr/local/bin
OUTPUT = bin
DIST = dist
STATIC_ARGS = -ldflags "-linkmode external -extldflags -static"
.PHONY: build static clean clean_go tidy install test test_cover release release-snapshot
# Build code according to caller OS and architecture
build:
go build -o $(OUTPUT)/$(NAME) $(CODE_DIR)/$(CODE)
# Build everything statically
static:
go build $(STATIC_ARGS) -o $(OUTPUT)/$(NAME) -a $(CODE_DIR)/$(CODE)
# Delete all compiled binaries
clean:
rm -rf $(OUTPUT)/$(NAME)
rm -rf $(DIST)/*
# Delete all dependencies go.sum files
clean_go:
find . -name "go.sum" -type f -exec rm -rf {} \;
# Remove all unused dependencies
tidy:
make clean
make clean_go
go mod tidy
# Install everything
# optional DEST=destination_path
install:
make clean
make build
sudo cp $(OUTPUT)/$(NAME) $(DEST)
# Run all tests
test:
go test ./cmd/osctrld/ -v
# Check test coverage
test_cover:
go test -cover ./cmd/osctrld/
# Release with goreleaser (for actual releases)
release:
goreleaser release --clean
# Create a snapshot release for testing without publishing
release-snapshot:
goreleaser release --snapshot --clean