forked from VEuPathDB/util-user-dataset-handler-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
66 lines (51 loc) · 2.12 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
VERSION = $(shell git describe --tags 2>/dev/null || echo "untagged")
COMMIT = $(shell (git rev-parse HEAD 2>/dev/null || echo "uncommitted") | cut -b 1-12)
DATE = $(shell date +"%Y-%m-%dT%T%z")
FILES = $(shell find . -name '*.go')
define go_build
env CGO_ENABLED=0 GOOS=linux \
go build \
-o bin/$(1) \
--ldflags="\
-X 'github.com/VEuPathDB/util-exporter-server/pkg/meta.version=$(VERSION)' \
-X 'github.com/VEuPathDB/util-exporter-server/pkg/meta.commit=$(COMMIT)' \
-X 'github.com/VEuPathDB/util-exporter-server/pkg/meta.buildDate=$(DATE)' \
-s -w" \
cmd/$(1)/main.go
endef
# Just build the server binary & api docs
.PHONY: build
build: bin/server bin/static-content/index.html
# Compile all binaries
.PHONY: build-all
build-all: bin/server bin/static-content/index.html bin/gen-config bin/check-config
# Build all release packages
.PHONY: gh-release
gh-release: bin/server-${GH_TAG}.tar.gz bin/check-config-${GH_TAG}.tar.gz bin/gen-config-${GH_TAG}.tar.gz
# Pre-push code testing
.PHONY: git-push
git-push:
@go test ./...
# Pre-commit doc generation
.PHONY: git-pre-commit
git-pre-commit: docs/api.html docs/index.html
@git add docs/api.html docs/index.html
bin/server: $(FILES)
$(call go_build,server)
bin/check-config: $(FILES)
$(call go_build,check-config)
bin/gen-config: $(FILES)
$(call go_build,gen-config)
bin/server-${GH_TAG}.tar.gz: bin/server bin/static-content/index.html
@cd bin && tar -czf server-${GH_TAG}.tar.gz server static-content && rm server && rm -rf static-content && cd ..
bin/gen-config-${GH_TAG}.tar.gz: bin/gen-config
@cd bin && tar -czf gen-config-${GH_TAG}.tar.gz gen-config && rm gen-config && cd ..
bin/check-config-${GH_TAG}.tar.gz: bin/check-config
@cd bin && tar -czf check-config-${GH_TAG}.tar.gz check-config && rm check-config && cd ..
bin/static-content/index.html: docs/api.html
@mkdir -p bin/static-content
@cp docs/api.html bin/static-content/api.html
docs/api.html: api.raml
@raml2html --theme raml2html-modern-theme api.raml > docs/api.html
docs/index.html: readme.adoc
@asciidoctor -b html5 -D docs/ -o index.html -r pygments.rb readme.adoc