-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathmakefile
108 lines (86 loc) · 3.5 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
PLATFORM=$(shell uname -s | tr '[:upper:]' '[:lower:]')
VERSION := $(shell grep -Eo '(v[0-9]+[\.][0-9]+[\.][0-9]+(-[a-zA-Z0-9]*)?)' version.go)
.PHONY: build build-server docker release check
build: check build-server build-webui
build-server:
CGO_ENABLED=1 go build -o ./bin/server github.com/moov-io/imagecashletter/cmd/server
build-webui:
cp $(shell go env GOROOT)/misc/wasm/wasm_exec.js ./docs/webui/assets/wasm_exec.js
GOOS=js GOARCH=wasm go build -o ./docs/webui/assets/imagecashletter.wasm github.com/moov-io/imagecashletter/docs/webui/
.PHONY: check
check:
ifeq ($(OS),Windows_NT)
@echo "Skipping checks on Windows, currently unsupported."
else
@wget -O lint-project.sh https://raw.githubusercontent.com/moov-io/infra/master/go/lint-project.sh
@chmod +x ./lint-project.sh
DISABLE_XMLENCODERCLOSE=true GOOS=js GOARCH=wasm COVER_THRESHOLD=70.0 ./lint-project.sh
endif
.PHONY: client
client:
@grep -rnwl './client/' -e 'Generated by: OpenAPI Generator' | xargs -n1 rm
# Generate all the new go code.
java -jar openapi-generator-cli.jar generate \
--input-spec ./openapi.yaml \
--output ./client \
--generator-name go \
--additional-properties isGoSubmodule=true,enumClassPrefix=true \
--package-name openapi
rm -f client/go.mod client/go.sum client/.travis.yml
# Format it and ensure that its good
go fmt ./...
go build github.com/moov-io/imagecashletter/client
go test ./client
.PHONY: clean
clean:
ifeq ($(OS),Windows_NT)
@echo "Skipping cleanup on Windows, currently unsupported."
else
@rm -rf ./bin/ openapi-generator-cli-*.jar
endif
dist: clean client build
ifeq ($(OS),Windows_NT)
CGO_ENABLED=1 GOOS=windows go build -o bin/imagecashletter.exe github.com/moov-io/imagecashletter/cmd/server
else
CGO_ENABLED=1 GOOS=$(PLATFORM) go build -o bin/imagecashletter-$(PLATFORM)-amd64 github.com/moov-io/imagecashletter/cmd/server
endif
dist-webui: build-webui
git config user.name "moov-bot"
git config user.email "[email protected]"
git add ./docs/webui/assets/wasm_exec.js ./docs/webui/assets/imagecashletter.wasm
git commit -m "chore: updating wasm webui" || echo "No changes to commit"
git push origin master
docker: clean docker-hub docker-openshift
docker-hub:
docker build --pull -t moov/imagecashletter:$(VERSION) -f Dockerfile .
docker tag moov/imagecashletter:$(VERSION) moov/imagecashletter:latest
docker-openshift:
docker build --pull -t quay.io/moov/imagecashletter:$(VERSION) -f Dockerfile.openshift --build-arg VERSION=$(VERSION) .
docker tag quay.io/moov/imagecashletter:$(VERSION) quay.io/moov/imagecashletter:latest
release: docker AUTHORS
go vet ./...
go test -coverprofile=cover-$(VERSION).out ./...
git tag -f $(VERSION)
release-push:
docker push moov/imagecashletter:$(VERSION)
docker push moov/imagecashletter:latest
quay-push:
docker push quay.io/moov/imagecashletter:$(VERSION)
docker push quay.io/moov/imagecashletter:latest
.PHONY: cover-test cover-web
cover-test:
go test -coverprofile=cover.out ./...
cover-web:
go tool cover -html=cover.out
# From https://github.com/genuinetools/img
.PHONY: AUTHORS
AUTHORS:
@$(file >$@,# This file lists all individuals having contributed content to the repository.)
@$(file >>$@,# For how it is generated, see `make AUTHORS`.)
@echo "$(shell git log --format='\n%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf)" >> $@
.PHONY: tagged-release
tagged-release:
@./tagged-release.sh $(VERSION)
.PHONY: preview-openapi
preview-openapi:
@docker run --rm -p 8080:8080 -e SWAGGER_JSON=/openapi.yaml -v $(shell pwd)/openapi.yaml:/openapi.yaml swaggerapi/swagger-ui