-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (46 loc) · 1.49 KB
/
Makefile
File metadata and controls
59 lines (46 loc) · 1.49 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
# Makefile for yt-api
# Version information
VERSION ?= 0.1.0
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "none")
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
# Build flags
LDFLAGS := -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.buildDate=$(BUILD_DATE)"
# Binary name
BINARY := yt-api
# Build directory
BUILD_DIR := build
.PHONY: all build clean test install help
all: build
## build: Build the binary with version information
build:
@echo "Building $(BINARY) version $(VERSION)..."
@mkdir -p $(BUILD_DIR)
go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY) ./cmd/yt-api
@echo "Build complete: $(BUILD_DIR)/$(BINARY)"
## install: Install the binary to GOPATH/bin
install:
@echo "Installing $(BINARY) version $(VERSION)..."
go install $(LDFLAGS) ./cmd/yt-api
@echo "Installed to $(shell go env GOPATH)/bin/$(BINARY)"
## test: Run all tests
test:
go test -v ./...
## test-coverage: Run tests with coverage report
test-coverage:
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
## clean: Remove build artifacts
clean:
@echo "Cleaning build artifacts..."
rm -rf $(BUILD_DIR)
rm -f coverage.out coverage.html
@echo "Clean complete"
## version: Show version information
version:
@echo "Version: $(VERSION)"
@echo "Commit: $(COMMIT)"
@echo "Date: $(BUILD_DATE)"
## help: Show this help message
help:
@echo "Available targets:"
@sed -n 's/^##//p' $(MAKEFILE_LIST) | column -t -s ':' | sed -e 's/^/ /'