-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
56 lines (45 loc) · 1.15 KB
/
Copy pathMakefile
File metadata and controls
56 lines (45 loc) · 1.15 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
.PHONY: build install clean test run
# Binary name
BINARY_NAME=ocli
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
# Build the binary
build:
$(GOBUILD) -o $(BINARY_NAME) -v .
# Install the binary to GOPATH/bin
install:
$(GOCMD) install .
# Clean build artifacts
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
# Run tests (if any exist)
test:
$(GOTEST) -v ./...
# Run the application directly
run:
$(GOCMD) run .
# Build for multiple platforms
build-all:
# Linux
GOOS=linux GOARCH=amd64 $(GOBUILD) -o builds/$(BINARY_NAME)-linux-amd64 .
GOOS=linux GOARCH=arm64 $(GOBUILD) -o builds/$(BINARY_NAME)-linux-arm64 .
# macOS
GOOS=darwin GOARCH=amd64 $(GOBUILD) -o builds/$(BINARY_NAME)-darwin-amd64 .
GOOS=darwin GOARCH=arm64 $(GOBUILD) -o builds/$(BINARY_NAME)-darwin-arm64 .
# Windows
GOOS=windows GOARCH=amd64 $(GOBUILD) -o builds/$(BINARY_NAME)-windows-amd64.exe .
# Tidy up dependencies
tidy:
$(GOMOD) tidy
# Create builds directory
prepare-builds:
mkdir -p builds
# Full release build
release: prepare-builds tidy build-all
@echo "Release builds created in builds/ directory"