-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (58 loc) · 1.9 KB
/
Makefile
File metadata and controls
71 lines (58 loc) · 1.9 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
GOBIN ?= $$(go env GOPATH)/bin
APP_NAME := scdl
BUILD_DIR := bin
VERSION := $(shell git describe --tags 2>/dev/null || echo "dev")
LDFLAGS := -ldflags "-X main.version=${VERSION} -s -w"
.PHONY: check
check: tidy fmt lint test build
.PHONY: build
build:
@go build ${LDFLAGS} ./cmd/scdl
.PHONY: test
test:
@go test -v ./...
.PHONY: tidy
tidy:
@go mod tidy
.PHONY: fmt
fmt:
@go fmt ./...
.PHONY: lint
lint:
@golangci-lint run
.PHONY: clean
clean:
@rm -rf ${BUILD_DIR}
# Helper to build for a specific os/arch
# Usage: make build-os-arch OS=linux ARCH=amd64
.PHONY: build-os-arch
build-os-arch:
@echo "Building ${APP_NAME} ${VERSION} for ${OS}/${ARCH}..."
@mkdir -p ${BUILD_DIR}
@if [ "${OS}" = "windows" ]; then \
GOOS=${OS} GOARCH=${ARCH} go build ${LDFLAGS} -o ${BUILD_DIR}/${APP_NAME}.exe ./cmd/scdl; \
zip -j ${BUILD_DIR}/${APP_NAME}_${VERSION}_${OS}-${ARCH}.zip ${BUILD_DIR}/${APP_NAME}.exe; \
rm ${BUILD_DIR}/${APP_NAME}.exe; \
else \
GOOS=${OS} GOARCH=${ARCH} go build ${LDFLAGS} -o ${BUILD_DIR}/${APP_NAME} ./cmd/scdl; \
tar -czf ${BUILD_DIR}/${APP_NAME}_${VERSION}_${OS}-${ARCH}.tar.gz -C ${BUILD_DIR} ${APP_NAME}; \
rm ${BUILD_DIR}/${APP_NAME}; \
fi
.PHONY: release
release: clean
@$(MAKE) build-os-arch OS=darwin ARCH=amd64
@$(MAKE) build-os-arch OS=darwin ARCH=arm64
@$(MAKE) build-os-arch OS=linux ARCH=386
@$(MAKE) build-os-arch OS=linux ARCH=amd64
@$(MAKE) build-os-arch OS=linux ARCH=arm64
@$(MAKE) build-os-arch OS=windows ARCH=386
@$(MAKE) build-os-arch OS=windows ARCH=amd64
@$(MAKE) build-os-arch OS=windows ARCH=arm64
@echo "Release builds created in ${BUILD_DIR}/"
.PHONY: install-go-test-coverage
install-go-test-coverage:
go install github.com/vladopajic/go-test-coverage/v2@latest
.PHONY: check-coverage
check-coverage: install-go-test-coverage
go test ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./...
${GOBIN}/go-test-coverage --config=./.testcoverage.yml