forked from calghar/gh-account-switcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (56 loc) · 1.94 KB
/
Makefile
File metadata and controls
67 lines (56 loc) · 1.94 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
.PHONY: build install clean test lint help
BINARY_NAME=gascli
VERSION?=2.0.0
BUILD_DIR=dist
GO=go
GOFLAGS=-ldflags="-s -w -X github.com/calghar/gas-cli/cmd.version=$(VERSION)"
## help: Show this help message
help:
@echo 'Usage:'
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
## build: Build the binary to ./bin (project directory)
build:
@echo "Building $(BINARY_NAME) v$(VERSION)..."
@mkdir -p bin
$(GO) build $(GOFLAGS) -o bin/$(BINARY_NAME) .
@echo "Build complete: ./bin/$(BINARY_NAME)"
## build-all: Build binaries for all platforms
build-all:
@echo "Building for all platforms..."
@mkdir -p $(BUILD_DIR)
GOOS=darwin GOARCH=amd64 $(GO) build $(GOFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 .
GOOS=darwin GOARCH=arm64 $(GO) build $(GOFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 .
GOOS=linux GOARCH=amd64 $(GO) build $(GOFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 .
GOOS=linux GOARCH=arm64 $(GO) build $(GOFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 .
GOOS=windows GOARCH=amd64 $(GO) build $(GOFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe .
@echo "All builds complete in $(BUILD_DIR)/"
## install: Build and install to $GOPATH/bin
install: build
@BIN_DIR=$$($(GO) env GOPATH)/bin; \
mkdir -p "$$BIN_DIR"; \
cp bin/$(BINARY_NAME) "$$BIN_DIR/$(BINARY_NAME)"; \
echo "Installed to $$BIN_DIR/$(BINARY_NAME)"
## test: Run tests
test:
$(GO) test -v -race -coverprofile=coverage.out ./...
## lint: Run golangci-lint
lint:
@which golangci-lint > /dev/null || (echo "golangci-lint not found, install from https://golangci-lint.run/" && exit 1)
golangci-lint run ./...
## clean: Remove build artifacts
clean:
@echo "Cleaning build artifacts..."
@rm -rf bin
@rm -f $(BINARY_NAME)
@rm -rf $(BUILD_DIR)
@rm -f coverage.out
@echo "Clean complete"
## deps: Download dependencies
deps:
$(GO) mod download
$(GO) mod tidy
## fmt: Format code
fmt:
$(GO) fmt ./...
gofmt -s -w .
.DEFAULT_GOAL := help