-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
56 lines (43 loc) · 1.32 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
55
56
# Project parameters
BINARY_NAME ?= steward
VERSION ?= $(shell git describe --tags --always --dirty --match=v* || (echo "command failed $$?"; exit 1))
IMAGE_NAME ?= docker.io/vshn/$(BINARY_NAME):$(VERSION)
docker_cmd ?= docker
docker_opts ?= --rm --tty --user "$$(id -u)"
vale_cmd ?= $(docker_cmd) run $(docker_opts) --volume "$${PWD}"/docs/modules/ROOT/pages:/pages ghcr.io/vshn/vale:2.15.5 --minAlertLevel=error --config=/pages/.vale.ini /pages
antora_preview_cmd ?= $(docker_cmd) run --rm --publish 35729:35729 --publish 2020:2020 --volume "${PWD}":/preview/antora ghcr.io/vshn/antora-preview:3.1.2.3 --style=syn --antora=docs
# Go parameters
GOCMD ?= go
GOBUILD ?= $(GOCMD) build
GOGEN ?= $(GOCMD) generate
GOCLEAN ?= $(GOCMD) clean
GOTEST ?= $(GOCMD) test
GOGET ?= $(GOCMD) get
.PHONY: all
all: test build docs
.PHONY: generate
generate:
$(GOGEN) ./...
.PHONY: build
build: generate
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) \
-o $(BINARY_NAME) \
-ldflags "-X main.Version=$(VERSION)"
@echo built '$(VERSION)'
.PHONY: test
test: generate
$(GOTEST) -v ./...
.PHONY: clean
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
.PHONY: docker
docker:
docker build -t $(IMAGE_NAME) .
@echo built image $(IMAGE_NAME)
.PHONY: docs-serve
docs-serve:
$(antora_preview_cmd)
.PHONY: docs-vale
docs-vale:
$(vale_cmd)