-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
66 lines (48 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
55
56
57
58
59
60
61
62
63
64
# 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)
# Antora variables
pages := $(shell find . -type f -name '*.adoc')
web_dir := ./_antora
docker_cmd ?= docker
docker_opts ?= --rm --tty --user "$$(id -u)"
antora_cmd ?= $(docker_cmd) run $(docker_opts) --volume "$${PWD}":/antora vshn/antora:1.3
antora_opts ?= --cache-dir=.cache/antora
vale_cmd ?= $(docker_cmd) run $(docker_opts) --volume "$${PWD}"/docs/modules/ROOT/pages:/pages vshn/vale:1.1 --minAlertLevel=error --config=/pages/.vale.ini /pages
# Go parameters
GOCMD ?= go
GOBUILD ?= $(GOCMD) build
GOCLEAN ?= $(GOCMD) clean
GOTEST ?= $(GOCMD) test
GOGET ?= $(GOCMD) get
.PHONY: all
all: test build docs
.PHONY: generate
generate:
go generate main.go
.PHONY: build
build: generate
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -v \
-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)
rm -rf $(web_dir)
.PHONY: docker
docker:
docker build -t $(IMAGE_NAME) .
@echo built image $(IMAGE_NAME)
.PHONY: docs
docs: $(web_dir)/index.html
$(web_dir)/index.html: playbook.yml $(pages)
$(antora_cmd) $(antora_opts) $<
.PHONY: check
check:
$(vale_cmd)