-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
50 lines (40 loc) · 1.02 KB
/
Makefile
File metadata and controls
50 lines (40 loc) · 1.02 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
BINARY := pulsarship
BUILD_DIR := build
VERSION := $(shell git describe --tags --abbrev=0)
TAG := $(shell git describe --tags --abbrev=0)
COMMIT := $(shell git rev-parse --short HEAD)
BUILDTIME := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
BUILDENV := $(shell go version)
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.tag=$(TAG)' -X 'main.commit=$(COMMIT)' -X 'main.buildTime=$(BUILDTIME)' -X 'main.buildEnv=$(BUILDENV)'
GOCMD := go
GOBUILD := $(GOCMD) build
GOTEST := $(GOCMD) test
GOVET := $(GOCMD) vet
GOFMT := gofmt -s -w
GOFILES := $(shell find . -type f -name '*.go' -not -path "./vendor/*")
.PHONY: all
all: fmt vet test build install
.PHONY: build
build:
$(GOBUILD) -ldflags "$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY) .
.PHONY: install
install: build
sudo install -Dm755 $(BUILD_DIR)/$(BINARY) /usr/bin/$(BINARY)
.PHONY: fmt
fmt:
$(GOFMT) $(GOFILES)
.PHONY: vet
vet:
$(GOVET) ./...
.PHONY: test
test:
$(GOTEST) ./...
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
.PHONY: tidy
tidy:
$(GOCMD) mod tidy
.PHONY: run
run:
$(GOCMD) run .