-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (74 loc) · 2.42 KB
/
Makefile
File metadata and controls
88 lines (74 loc) · 2.42 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
.PHONY: all build test clean install deps lint release snapshot
BINARY_NAME=git-branch-delete
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT_SHA ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_TIME ?= $(shell date -u '+%Y-%m-%d_%H:%M:%S')
LDFLAGS=-ldflags "-s -w -X github.com/bral/git-branch-delete-go/cmd.Version=${VERSION} -X github.com/bral/git-branch-delete-go/cmd.CommitSHA=${COMMIT_SHA} -X github.com/bral/git-branch-delete-go/cmd.BuildTime=${BUILD_TIME}"
# Default target
all: deps build test
# Install dependencies
deps:
@echo "Installing dependencies..."
go mod download
go mod tidy
# Build the binary
build: deps
@echo "Building ${BINARY_NAME} version ${VERSION}..."
mkdir -p bin
CGO_ENABLED=0 go build ${LDFLAGS} -o bin/${BINARY_NAME}
# Run tests
test: deps
@echo "Running tests..."
go test -v ./...
# Run tests with coverage
test-coverage:
@echo "Running tests with coverage..."
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
# Run linter
lint:
@echo "Running linter..."
golangci-lint run
# Clean build artifacts
clean:
@echo "Cleaning..."
rm -rf bin/
rm -f coverage.out coverage.html
go clean -testcache
# Install to $GOPATH/bin
install: build
@echo "Installing to ${GOPATH}/bin..."
mv bin/${BINARY_NAME} ${GOPATH}/bin/${BINARY_NAME}
# Create a new release
release:
@echo "Creating release ${VERSION}..."
goreleaser release --clean
# Create a snapshot release
snapshot:
@echo "Creating snapshot..."
goreleaser release --snapshot --clean
# Run the program
run: build
@echo "Running ${BINARY_NAME}..."
./bin/${BINARY_NAME}
# Show version info
version:
@echo "Version: ${VERSION}"
@echo "Commit: ${COMMIT_SHA}"
@echo "Build Time: ${BUILD_TIME}"
# Help target
help:
@echo "Available targets:"
@echo " all - Install dependencies, build, and test"
@echo " deps - Install dependencies"
@echo " build - Build the binary"
@echo " test - Run tests"
@echo " test-coverage - Run tests with coverage"
@echo " lint - Run linter"
@echo " clean - Clean build artifacts"
@echo " install - Install to GOPATH/bin"
@echo " release - Create a new release"
@echo " snapshot - Create a snapshot release"
@echo " run - Run the program"
@echo " version - Show version info"
@echo " help - Show this help"