forked from kopeio/kexpand
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (46 loc) · 2.22 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
all: gocode
DOCKER_REGISTRY=kopeio
UNIQUE:=$(shell date +%s)
GOVERSION=1.7.4
GITSHA := $(git describe --always)
ifndef VERSION
VERSION=0.2
endif
# See http://stackoverflow.com/questions/18136918/how-to-get-current-relative-directory-of-your-makefile
MAKEDIR:=$(strip $(shell dirname "$(realpath $(lastword $(MAKEFILE_LIST)))"))
gocode:
GO15VENDOREXPERIMENT=1 go install -ldflags "-X main.BuildVersion=${VERSION}" github.com/vinissimus/kexpand
gocode_docker:
GO15VENDOREXPERIMENT=1 CGO_ENABLED=0 GOOS=linux go install -ldflags "-s -X main.BuildVersion=${VERSION}" -a -installsuffix cgo github.com/vinissimus/kexpand
crossbuild-in-docker:
docker pull golang:${GOVERSION} # Keep golang image up to date
docker run --name=kexpand-build-${UNIQUE} -e STATIC_BUILD=yes -e VERSION=${VERSION} -v ${MAKEDIR}:/go/src/github.com/vinissimus/kexpand golang:${GOVERSION} make -f /go/src/github.com/vinissimus/kexpand/Makefile crossbuild
docker cp kexpand-build-${UNIQUE}:/go/.build .
crossbuild:
mkdir -p .build/dist/
GOOS=darwin GOARCH=amd64 go build -a ${EXTRA_BUILDFLAGS} -o .build/dist/darwin/amd64/kexpand -ldflags "${EXTRA_LDFLAGS} -X main.BuildVersion=${VERSION} -X main.GitVersion=${GITSHA}" github.com/vinissimus/kexpand
GOOS=linux GOARCH=amd64 go build -a ${EXTRA_BUILDFLAGS} -o .build/dist/linux/amd64/kexpand -ldflags "${EXTRA_LDFLAGS} -X main.BuildVersion=${VERSION} -X main.GitVersion=${GITSHA}" github.com/vinissimus/kexpand
kexpand-dist: crossbuild-in-docker
mkdir -p .build/dist/
(sha1sum .build/dist/darwin/amd64/kexpand | cut -d' ' -f1) > .build/dist/darwin/amd64/kexpand.sha1
(sha1sum .build/dist/linux/amd64/kexpand | cut -d' ' -f1) > .build/dist/linux/amd64/kexpand.sha1
version-dist: kexpand-dist
gofmt:
gofmt -w -s main.go
gofmt -w -s cmd
gofmt -w -s pkg
build-in-docker:
docker run -it -v `pwd`:/src golang:1.7 /src/images/kexpand/onbuild.sh
image: build-in-docker
docker build -t ${DOCKER_REGISTRY}/kexpand -f images/kexpand/Dockerfile .
push: image
docker push ${DOCKER_REGISTRY}/kexpand
# --------------------------------------------------
# Continuous integration targets
ci: images test govet
echo "Done"
govet:
go vet \
github.com/vinissimus/kexpand/cmd/...
test:
go test github.com/vinissimus/kexpand/cmd/...