-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (49 loc) · 1.73 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
.PHONY: deps clean build lint changelog snapshot release client
# Check for required command tools to build or stop immediately
EXECUTABLES = git go find pwd
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
GO ?= latest
BINARY = gsonata
MAIN = $(shell pwd)/cmd/main.go
BUILDDIR = $(shell pwd)/build
VERSION ?= 0.0.1
GITREV = $(shell git rev-parse --short HEAD)
BUILDTIME = $(shell date +'%FT%TZ%z')
LDFLAGS=-ldflags '-X main.version=${VERSION} -X main.commit=${GITREV} -X main.date=${BUILDTIME}'
GO_BUILDER_VERSION=v1.16
default: build
deps:
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
go get -u github.com/goreleaser/goreleaser
go get -u github.com/git-chglog/git-chglog/cmd/git-chglog
go get -u golang.org/x/tools/cmd/goimports
build:
go build ${LDFLAGS} -o $(BUILDDIR)/${BINARY} $(MAIN)
@echo 'Build $(BINARY) done.'
client:
go build ${LDFLAGS} -o $(BUILDDIR)/client $(shell pwd)/cmd/client/main.go
@echo 'Build client done.'
changelog:
git-chglog $(VERSION) > CHANGELOG.md
clean:
rm -rf $(BUILDDIR)/
lint:
golangci-lint run --fix
snapshot:
docker run --rm --privileged \
-e PRIVATE_KEY=$(PRIVATE_KEY) \
-v $(CURDIR):/go-sonata-server \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(GOPATH)/src:/go/src \
-w /go-sonata-server \
goreng/golang-cross:$(GO_BUILDER_VERSION) --snapshot --rm-dist
release: changelog
docker run --rm --privileged \
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
-e PRIVATE_KEY=$(PRIVATE_KEY) \
-v $(CURDIR):/go-sonata-server \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(GOPATH)/src:/go/src \
-w /go-sonata-server \
goreng/golang-cross:$(GO_BUILDER_VERSION) --rm-dist --release-notes=CHANGELOG.md