-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
53 lines (36 loc) · 1.08 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
.PHONY: build test install binaries help image push clean
all: test build
help:
@echo make test build install
@echo make binaries
@echo make image push
@echo make clean
TRAVIS_TAG?=$(shell git describe --tags HEAD)
TAG:=$(TRAVIS_TAG)
gobuild_args := -ldflags "-s -w -X main.Version=$(TAG)"
build: echo-json
echo-json: echo-json.go
go build $(gobuild_args)
test:
go test
$$GOPATH/bin/echo-json: echo-json
cp $< $@
install: $$GOPATH/bin/echo-json
dist:
mkdir $@
DEPS:=*.go go.sum Makefile
dist/echo-json.exe: $(DEPS)
GOOS=windows GOARCH=amd64 go build $(gobuild_args) -o $@
dist/echo-json.%: $(DEPS)
GOOS=$* GOARCH=amd64 go build $(gobuild_args) -o $@
binaries: dist $(addprefix dist/echo-json.,linux darwin exe)
@ls -l dist
image:
docker build --no-cache --build-arg TAG="$(TAG)" --pull -t filex/echo-json:$(TAG) .
push: image
docker push filex/echo-json:$(TAG)
docker tag filex/echo-json:$(TAG) filex/echo-json:latest
docker push filex/echo-json:latest
clean:
rm -rf dist/ echo-json
- docker rmi -f $$(docker images -f 'reference=filex/echo-json' --format '{{.ID}}')