-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (41 loc) · 1.38 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
VERSION=0.1.0
SHELL=sh
PATH:=$(GOPATH)/bin:$(PATH)
BIN_NAME=aws-es-proxy-go
BUILD_DIR=./build
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
GOOS?=$(shell go env GOOS)
GOARCH?=$(shell go env GOARCH)
CGO_ENABLED=0
VERSION_PACKAGE=main
GIT_COMMIT?=$(shell git rev-parse --short HEAD)
GIT_DIRTY?=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
GIT_BUILD_DATE=$(shell date --utc '+%Y-%m-%dT%H:%M:%SZ')
GIT_BUILD_GO_VERSION=$(shell go version)
BUILD_LDFLAGS=-s -w \
-X $(VERSION_PACKAGE).version=$(VERSION) \
-X $(VERSION_PACKAGE).commit=$(GIT_COMMIT)$(GIT_DIRTY) \
-X $(VERSION_PACKAGE).buildDate=$(GIT_BUILD_DATE) \
-X $(VERSION_PACKAGE).buildGoVersion=$(GIT_BUILD_DATE)
# embed version and revision
CURRENT_VERSION=$(shell git log --merges --oneline | perl -ne 'if(m/^.+Merge pull request \#[0-9]+ from .+\/bump-version-([0-9\.]+)/){print $$1;exit}')
.PHONY: run clean install_deps build vet lint fmt test
default: test build
run:
CGO_ENABLED=$(CGO_ENABLED) go run -installsuffix esproxy -ldflags "$(BUILD_LDFLAGS)" . -config ./example/sample.json
clean:
rm -rf "$(BUILD_DIR)/*"
install_deps:
# do nothing
build:
CGO_ENABLED=$(CGO_ENABLED) go build -o "$(BUILD_DIR)/$(BIN_NAME)" -installsuffix esproxy -ldflags "$(BUILD_LDFLAGS)" .
vet: lint
go vet ./...
lint:
# lint: TODO
fmt:
gofmt -s -l -w $(GOFMT_FILES)
test:
# test: TODO
#build-docker:
# docker build .