-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
68 lines (58 loc) · 2.02 KB
/
Makefile
File metadata and controls
68 lines (58 loc) · 2.02 KB
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
NAME := lbex
VERSION := 0.1.12
TYPE := alpha
COMMIT := $(shell git rev-parse HEAD)
IMAGE := sostheim/lbex
TAG ?= latest
godep=GOPATH=$(shell godep path):${GOPATH}
build:
@go build -ldflags "-X main.LbexMajorMinorPatch=$(VERSION) \
-X main.LbexType=$(TYPE) \
-X main.LbexGitCommit=$(COMMIT)"
compile: deps
@rm -rf build/
@$(GODEP) gox -ldflags "-X main.LbexMajorMinorPatch=$(VERSION) \
-X main.LbexType=$(TYPE) \
-X main.LbexGitCommit=$(COMMIT) -w" \
-osarch="linux/386" \
-osarch="linux/amd64" \
-osarch="darwin/amd64" \
-output "build/{{.OS}}_{{.Arch}}/$(NAME)" \
./...
install:
@godep go install -ldflags "-X main.LbexMajorMinorPatch=$(VERSION) \
-X main.LbexType=$(TYPE) \
-X main.LbexGitCommit=$(COMMIT) -w"
deps:
go get github.com/mitchellh/gox
go get github.com/tools/godep
dist: compile
$(eval FILES := $(shell ls build))
@rm -rf dist && mkdir dist
@for f in $(FILES); do \
(cp $(shell pwd)/nginx/*.tmpl $(shell pwd)/build/$$f); \
(cd $(shell pwd)/build/$$f && tar -cvzf ../../dist/$$f.tar.gz *); \
(cd $(shell pwd)/dist && shasum -a 512 $$f.tar.gz > $$f.sha512); \
echo $$f; \
done
container:
@$(GODEP) gox -ldflags "-X main.LbexMajorMinorPatch=$(VERSION) \
-X main.LbexType=$(TYPE) \
-X main.LbexGitCommit=$(COMMIT) -w" \
-osarch="linux/amd64" \
-output "build/{{.OS}}_{{.Arch}}/$(NAME)" \
./...
docker build --rm --pull --tag $(IMAGE):$(TAG) .
tag: container
docker tag $(IMAGE):$(TAG) $(IMAGE):$(COMMIT)
push: tag
docker push $(IMAGE):$(COMMIT)
docker push $(IMAGE):$(TAG)
release: dist push
@latest_tag=$$(git describe --tags `git rev-list --tags --max-count=1`); \
comparison="$$latest_tag..HEAD"; \
if [ -z "$$latest_tag" ]; then comparison=""; fi; \
changelog=$$(git log $$comparison --oneline --no-merges --reverse); \
github-release sostheim/$(NAME) $(VERSION) "$$(git rev-parse --abbrev-ref HEAD)" "**Changelog**<br/>$$changelog" 'dist/*'; \
git pull
.PHONY: build compile install deps dist release push tag container