forked from crewjam/etcd-aws
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
48 lines (38 loc) · 1.4 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
.PHONY:
GO_SOURCES=$(shell find . -name \*.go)
SOURCES=$(GO_SOURCES)
PLATFORM_BINARIES=dist/etcd-aws.Linux.x86_64
ETCD_VERSION=3.1.5
IMAGE_NAME=topochan/etcd-aws
GITHUB_USER=topochan
GITHUB_REPOSITORY=etcd-aws
all: $(PLATFORM_BINARIES)
clean:
-rm $(PLATFORM_BINARIES)
dist/cacert.pem:
[ -d dist ] || mkdir dist
curl -s -o $@ https://curl.haxx.se/ca/cacert.pem
dist/etcd.Linux.x86_64:
[ -d dist ] || mkdir dist
curl -L -s https://github.com/coreos/etcd/releases/download/v$(ETCD_VERSION)/etcd-v$(ETCD_VERSION)-linux-amd64.tar.gz |\
tar -C dist -xzf -
cp dist/etcd-v$(ETCD_VERSION)-linux-amd64/etcd dist/etcd.Linux.x86_64
rm -rf dist/etcd-v$(ETCD_VERSION)-linux-amd64
dist/etcd-aws.Linux.x86_64: $(SOURCES)
[ -d dist ] || mkdir dist
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags '-s' \
-o $@ ./etcd-aws.go ./backup.go ./lifecycle.go
container: dist/cacert.pem dist/etcd-aws.Linux.x86_64 dist/etcd.Linux.x86_64
docker build -t $(IMAGE_NAME) .
check:
go test ./...
lint:
go fmt ./...
goimports -w $(GO_SOURCES)
release: lint check container $(PLATFORM_BINARIES)
@[ ! -z "$(VERSION)" ] || (echo "you must specify the VERSION"; false)
which ghr >/dev/null || go get github.com/tcnksm/ghr
ghr -u $(GITHUB_USER) -r $(GITHUB_REPOSITORY) --delete v$(VERSION) dist/
docker tag $(IMAGE_NAME) $(IMAGE_NAME):$(VERSION)
docker push $(IMAGE_NAME)
docker push $(IMAGE_NAME):$(VERSION)