forked from baetyl/baetyl-cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (38 loc) · 1.24 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
MODULE:=baetyl-cloud
SRC_FILES:=$(shell find . -type f -name '*.go')
export DOCKER_CLI_EXPERIMENTAL=enabled
GIT_TAG:=$(shell git tag --contains HEAD|awk 'END {print}')
GIT_REV:=git-$(shell git rev-parse --short HEAD)
VERSION:=$(if $(GIT_TAG),$(GIT_TAG),$(GIT_REV))
GO_FLAGS:=-s -w -X github.com/baetyl/baetyl-go/v2/utils.REVISION=$(GIT_REV) -X github.com/baetyl/baetyl-go/v2/utils.VERSION=$(VERSION)
GO_PROXY:=$(shell go env GOPROXY)
GO_TEST_FLAGS:=-race -short -covermode=atomic -coverprofile=coverage.txt
GO_TEST_PKGS:=$(shell go list ./...)
REGISTRY?=
.PHONY: all
all: build
.PHONY: build
build: $(SRC_FILES)
env CGO_ENABLED=0 go build -o output/$(MODULE) -ldflags "$(GO_FLAGS)" .
.PHONY: image
image:
@echo "BUILDX: $(REGISTRY)$(MODULE):$(VERSION)"
@-docker buildx create --name $(MODULE)
@docker buildx use $(MODULE)
docker buildx build --push \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
-t $(REGISTRY)$(MODULE):$(VERSION) \
--build-arg GOPROXY="$(GO_PROXY)" \
--build-arg GIT_REV="$(GIT_REV)" \
--build-arg VERSION="$(VERSION)" \
-f Dockerfile .
.PHONY: test
test: fmt
@go test ${GO_TEST_FLAGS} ${GO_TEST_PKGS}
@go tool cover -func=coverage.txt | grep total
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: clean
clean:
@rm -rf output