-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
54 lines (44 loc) · 1.4 KB
/
Makefile
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
NAME ?= yip
PACKAGE_NAME ?= $(NAME)
PACKAGE_CONFLICT ?= $(PACKAGE_NAME)-beta
REVISION := $(shell git rev-parse --short HEAD || echo dev)
VERSION := $(shell git describe --tags || echo $(REVISION))
VERSION := $(shell echo $(VERSION) | sed -e 's/^v//g')
ITTERATION := $(shell date +%s)
BUILD_PLATFORMS ?= -osarch="linux/amd64" -osarch="linux/386" -osarch="linux/arm"
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
# go tool nm ./yip | grep Commit
override LDFLAGS += -X "github.com/mudler/yip/cmd.BuildTime=$(shell date -u '+%Y-%m-%d %I:%M:%S %Z')"
override LDFLAGS += -X "github.com/mudler/yip/cmd.BuildCommit=$(shell git rev-parse HEAD)"
.PHONY: all
all: build
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: test
test:
go mod tidy -compat=1.22
go run github.com/onsi/ginkgo/v2/ginkgo -race -r ./...
.PHONY: coverage
coverage:
go run github.com/onsi/ginkgo/v2/ginkgo -race -coverprofile=coverage.txt -covermode=atomic ./...
.PHONY: help
help:
# make all => test lint build
# make test - run project tests
# make lint - check project code style
# make build - build project for all supported OSes
.PHONY: clean
clean:
rm -rf release/
.PHONY: build
build:
CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)'
.PHONY: build-small
build-small:
@$(MAKE) LDFLAGS+="-s -w" build
upx --brute -1 $(NAME)
.PHONY: lint
lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2
golangci-lint run