-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
46 lines (36 loc) · 1.27 KB
/
Makefile
File metadata and controls
46 lines (36 loc) · 1.27 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
.PHONY: build build-static clean test release lint check fmt vet
GO := go
GOFLAGS := -v
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -s -w -X main.version=$(VERSION)
build:
mkdir -p bin
$(GO) build $(GOFLAGS) -o bin/bsubio ./cmd/bsubio
build-static:
mkdir -p bin
CGO_ENABLED=0 $(GO) build $(GOFLAGS) -ldflags="$(LDFLAGS)" -o bin/bsubio ./cmd/bsubio
release:
@echo "Building static binaries for release..."
mkdir -p bin/release
@for os in linux darwin; do \
for arch in amd64 arm64; do \
echo "Building $$os/$$arch..."; \
GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 $(GO) build -ldflags="$(LDFLAGS)" -o bin/release/bsubio-$$os-$$arch ./cmd/bsubio; \
done; \
done
@echo "Building windows/amd64..."
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 $(GO) build -ldflags="$(LDFLAGS)" -o bin/release/bsubio-windows-amd64.exe ./cmd/bsubio
@echo "Release binaries built in bin/release/"
fmt:
go fmt ./...
vet:
go vet ./...
lint:
which golangci-lint > /dev/null || (echo "golangci-lint not found. Install with: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest" && exit 1)
GOFLAGS="-buildvcs=false" golangci-lint run ./...
test:
$(GO) test $(GOFLAGS) ./...
check: fmt vet lint test
clean:
rm -rf bin
rm -f bsubio