-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
97 lines (75 loc) · 2.42 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
PROJECT := ArangoDBStarter
SCRIPTDIR := $(shell pwd)
ROOTDIR := $(shell cd $(SCRIPTDIR) && pwd)
VERSION:= $(shell cat $(ROOTDIR)/VERSION)
COMMIT := $(shell git rev-parse --short HEAD)
GOBUILDDIR := $(SCRIPTDIR)/.gobuild
SRCDIR := $(SCRIPTDIR)
BINDIR := $(ROOTDIR)/bin
ORGPATH := github.com/neunhoef
ORGDIR := $(GOBUILDDIR)/src/$(ORGPATH)
REPONAME := $(PROJECT)
REPODIR := $(ORGDIR)/$(REPONAME)
REPOPATH := $(ORGPATH)/$(REPONAME)
GOPATH := $(GOBUILDDIR)
GOVERSION := 1.7.4-alpine
ifndef GOOS
GOOS := linux
endif
ifndef GOARCH
GOARCH := amd64
endif
ifndef DOCKERNAMESPACE
DOCKERNAMESPACE := arangodb
endif
BINNAME := arangodb-$(GOOS)-$(GOARCH)
BIN := $(BINDIR)/$(BINNAME)
SOURCES := $(shell find $(SRCDIR) -name '*.go')
.PHONY: all clean deps docker build build-local
all: build
clean:
rm -Rf $(BIN) $(GOBUILDDIR)
local:
@${MAKE} -B GOOS=$(shell go env GOHOSTOS) GOARCH=$(shell go env GOHOSTARCH) build-local
build: $(BIN)
build-local: build
@ln -sf $(BIN) $(ROOTDIR)/arangodb
deps:
@${MAKE} -B -s $(GOBUILDDIR)
$(GOBUILDDIR):
@mkdir -p $(ORGDIR)
@rm -f $(REPODIR) && ln -s ../../../.. $(REPODIR)
GOPATH=$(GOBUILDDIR) go get github.com/cenkalti/backoff
GOPATH=$(GOBUILDDIR) go get github.com/fsouza/go-dockerclient
GOPATH=$(GOBUILDDIR) go get github.com/juju/errgo
GOPATH=$(GOBUILDDIR) go get github.com/op/go-logging
GOPATH=$(GOBUILDDIR) go get github.com/spf13/cobra
GOPATH=$(GOBUILDDIR) go get github.com/coreos/go-semver/semver
$(BIN): $(GOBUILDDIR) $(SOURCES)
@mkdir -p $(BINDIR)
docker run \
--rm \
-v $(SRCDIR):/usr/code \
-e GOPATH=/usr/code/.gobuild \
-e GOOS=$(GOOS) \
-e GOARCH=$(GOARCH) \
-e CGO_ENABLED=0 \
-w /usr/code/ \
golang:$(GOVERSION) \
go build -a -installsuffix netgo -tags netgo -ldflags "-X main.projectVersion=$(VERSION) -X main.projectBuild=$(COMMIT)" -o /usr/code/bin/$(BINNAME) $(REPOPATH)
docker: build
docker build -t arangodb/arangodb-starter .
docker-push: docker
ifneq ($(DOCKERNAMESPACE), arangodb)
docker tag arangodb/arangodb-starter $(DOCKERNAMESPACE)/arangodb-starter
endif
docker push $(DOCKERNAMESPACE)/arangodb-starter
docker-push-version: docker
docker tag arangodb/arangodb-starter arangodb/arangodb-starter:$(VERSION)
docker push arangodb/arangodb-starter:$(VERSION)
release-patch: $(GOBUILDDIR)
go run ./tools/release.go -type=patch
release-minor: $(GOBUILDDIR)
go run ./tools/release.go -type=minor
release-major: $(GOBUILDDIR)
go run ./tools/release.go -type=major