-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (73 loc) · 2.91 KB
/
Makefile
File metadata and controls
83 lines (73 loc) · 2.91 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
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "v0.1.0")
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
BUILD_USER ?= $(shell whoami)@$(shell hostname)
PKG := github.com/user-cube/aws-cli-manager/v2
LDFLAGS := -ldflags "-X $(PKG)/cmd.Version=$(VERSION) -X $(PKG)/cmd.BuildDate=$(BUILD_DATE) -X $(PKG)/cmd.GitCommit=$(COMMIT) -X $(PKG)/cmd.BuildUser=$(BUILD_USER)"
.PHONY: all
all: clean build
.PHONY: build
build:
@echo "Building aws-cli-manager $(VERSION) ($(COMMIT))"
@go build $(LDFLAGS) -o aws-cli-manager main.go
.PHONY: install
install:
@echo "Installing aws-cli-manager $(VERSION) to GOPATH"
@go install $(LDFLAGS)
.PHONY: clean
clean:
@echo "Cleaning build artifacts"
@rm -f aws-cli-manager
@rm -rf dist
.PHONY: test
test:
@echo "Running tests"
@go test -v ./...
.PHONY: lint
lint:
@echo "Running linters"
@if command -v golangci-lint > /dev/null; then \
golangci-lint run ./...; \
else \
echo "golangci-lint not found, skipping lint"; \
fi
.PHONY: release
release: clean
@echo "Creating release with GoReleaser $(VERSION)"
@if ! command -v goreleaser > /dev/null; then \
echo "Error: goreleaser not found. Install with 'go install github.com/goreleaser/goreleaser@latest'"; \
exit 1; \
fi
@VERSION=$(VERSION) GIT_COMMIT=$(COMMIT) BUILD_DATE=$(BUILD_DATE) goreleaser release --clean
.PHONY: release-snapshot
release-snapshot: clean
@echo "Creating snapshot release with GoReleaser (no publish)"
@if ! command -v goreleaser > /dev/null; then \
echo "Error: goreleaser not found. Install with 'go install github.com/goreleaser/goreleaser@latest'"; \
exit 1; \
fi
@VERSION=$(VERSION) GIT_COMMIT=$(COMMIT) BUILD_DATE=$(BUILD_DATE) goreleaser release --snapshot --clean
.PHONY: build-release
build-release: clean
@echo "Building release version of aws-cli-manager $(VERSION) ($(COMMIT))"
@go build $(LDFLAGS) -o aws-cli-manager main.go
@echo "Built aws-cli-manager binary with release information"
@echo "Version: $(VERSION)"
@echo "Commit: $(COMMIT)"
@echo "Build Date: $(BUILD_DATE)"
@echo "Run ./aws-cli-manager version to verify"
.PHONY: help
help:
@echo "aws-cli-manager Makefile"
@echo "---------------"
@echo "Available targets:"
@echo " all - Clean and build aws-cli-manager"
@echo " build - Build the aws-cli-manager binary"
@echo " install - Install aws-cli-manager to your GOPATH/bin"
@echo " clean - Remove built binary and dist directory"
@echo " test - Run tests"
@echo " lint - Run linters (requires golangci-lint)"
@echo " release - Create a full release using GoReleaser"
@echo " release-snapshot - Create a local release snapshot for testing (no publish)"
@echo " build-release - Build aws-cli-manager binary with release information"
@echo " help - Show this help message"