-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (45 loc) · 1.26 KB
/
Makefile
File metadata and controls
55 lines (45 loc) · 1.26 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
# Go parameters
BINARY_NAME=gitx
CMD_PATH=./cmd/gitx
BUILD_DIR=./build
# Versioning -- NEW SECTION
# Get the latest git tag, or fallback to "dev" if no tags are found.
VERSION := $(shell git describe --tags --abbrev=0 2>/dev/null || echo "dev")
LDFLAGS := -ldflags="-X 'main.version=$(VERSION)'"
# Default target executed when you run `make`
all: build
# Syncs dependencies
sync:
@echo "Syncing dependencies..."
@go mod tidy
@echo "Dependencies synced."
# Builds the binary
build: sync
@echo "Building the application..."
@mkdir -p $(BUILD_DIR)
@go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) $(CMD_PATH)
@echo "Binary available at $(BUILD_DIR)/$(BINARY_NAME)"
# Runs the application
run: build
@echo "Running $(BINARY_NAME)..."
@$(BUILD_DIR)/$(BINARY_NAME)
# Runs all tests
test:
@echo "Running tests..."
@go test -v ./...
# Runs golangci-lint
ci:
@echo "Running golangci-lint..."
@golangci-lint run
# Installs the binary to /usr/local/bin
install: build
@echo "Installing $(BINARY_NAME)..."
@go install $(LDFLAGS) $(CMD_PATH)
@echo "$(BINARY_NAME) installed successfully"
# Cleans the build artifacts
clean:
@echo "Cleaning up..."
@rm -rf $(BUILD_DIR)
@echo "Cleanup complete."
#PHONY targets are not files
.PHONY: all sync build run test ci install clean