-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
194 lines (160 loc) · 6.87 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
all: help
TAG = annorepo
DOCKER_DOMAIN = registry.diginfra.net/tt
SHELL=/bin/bash
CLIENT_SRC=$(shell find client/src/ -type f)
COMMON_SRC=$(shell find common/src/ -type f)
version_fn = $(shell cat .make/.version 2>/dev/null)
.make:
mkdir -p .make
.make/.version: .make pom.xml
mvn help:evaluate -Dexpression=project.version -q -DforceStdout > .make/.version
server/target/annorepo-server-$(call version_fn).jar: .make/.version $(shell find server/src common/src -type f) pom.xml server/pom.xml
mvn --projects server --also-make package
client/target/annorepo-client-$(call version_fn).jar: .make/.version $(shell find client/src common/src -type f) pom.xml client/pom.xml
mvn --projects client --also-make package
.PHONY: build
build: .make/.version server/target/annorepo-server-$(call version_fn).jar client/target/annorepo-client-$(call version_fn).jar
.PHONY: build-server
build-server: .make/.version server/target/annorepo-server-$(call version_fn).jar
.PHONY: build-client
build-client: .make/.version client/target/annorepo-client-$(call version_fn).jar client/readme.md
.make/install-client: .make client/pom.xml $(CLIENT_SRC) common/pom.xml $(COMMON_SRC)
mvn --projects client --also-make install
@touch $@
.PHONY: install-client
install-client: .make/install-client
.PHONY: run-server-with-auth
run-server-with-auth: build-server
@make start-mongodb
AR_WITH_AUTHENTICATION=true AR_ROOT_API_KEY=root java -jar server/target/annorepo-server-$(call version_fn).jar server config.yml
.PHONY: run-server-without-auth
run-server-without-auth: build-server
@make start-mongodb
AR_WITH_AUTHENTICATION=false java -jar server/target/annorepo-server-$(call version_fn).jar server config.yml
.PHONY: run-env
run-env: build-server
java -jar server/target/annorepo-server-$(call version_fn).jar env
.PHONY: docker-run
docker-run: k8s/local/docker-compose.yml
cd k8s/local && docker compose up &
.PHONY: docker-stop
docker-stop: k8s/local/docker-compose.yml
cd k8s/local && docker compose down
.make/.docker: .make k8s/annorepo-server/Dockerfile-multistage
docker build -t $(TAG):$(call version_fn) -f k8s/annorepo-server/Dockerfile-multistage .
@touch $@
.PHONY: docker-image
docker-image: .make/.docker
.make/.push-server: build k8s/annorepo-server/Dockerfile
docker build -t $(TAG):$(call version_fn) --platform=linux/amd64 -f k8s/annorepo-server/Dockerfile .
docker tag $(TAG):$(call version_fn) $(DOCKER_DOMAIN)/$(TAG):$(call version_fn)
docker push $(DOCKER_DOMAIN)/$(TAG):$(call version_fn)
@touch $@
.make/.push-updater: k8s/updater/Dockerfile
docker build -t $(TAG)-updater:$(call version_fn) --platform=linux/amd64 -f k8s/updater/Dockerfile .
docker tag $(TAG)-updater:$(call version_fn) $(DOCKER_DOMAIN)/$(TAG)-updater:$(call version_fn)
docker push $(DOCKER_DOMAIN)/$(TAG)-updater:$(call version_fn)
@touch $@
.PHONY: push
push: clean build-server .make/.push-server .make/.push-updater
.PHONY: clean
clean:
rm -rf .make */src/generated/*/*
mvn clean
.PHONY: version-update
version-update:
mvn versions:set && mvn versions:commit && find . -name dependency-reduced-pom.xml -delete
make client/readme.md
.make/.deploy: build-client
export GPG_TTY=$(tty)
mvn clean install
mvn --projects client --also-make deploy -P release
open https://repo.maven.apache.org/maven2/io/github/knaw-huc/annorepo-client/
open https://central.sonatype.com/search?q=annorepo
@touch $@
.PHONY: deploy
deploy: .make/.deploy
.make/.dokka: $(shell find */src -type f) pom.xml */pom.xml
mvn dokka:dokka --projects client --also-make
rm -rf client/dokka
mv client/target/dokka client/dokka
rm -rf common/dokka
mv common/target/dokka common/dokka
@touch $@
.PHONY: dokka
dokka: .make/.dokka
client/readme.md: client/src/test/resources/readme.md client/pom.xml
mvn --projects client --also-make resources:testResources
echo "<!--- DO NOT EDIT THIS FILE! This file is generated from client/src/test/resources/readme.md; edit that file instead. -->" > client/readme.md
cat client/target/test-classes/readme.md >> client/readme.md
.PHONY: release
release:
git pull && \
git push && \
make version-update && \
git commit -a -m "bump version to $(call version_fn)" && \
git push && \
gh release create v$(call version_fn) && \
make deploy
.PHONY: tests
tests:
mvn test -Dmaven.plugin.validation=VERBOSE
.PHONY: start-mongodb
start-mongodb:
docker start mongodb6 || docker run --name mongodb6 -d -p 27017:27017 -v ~/local/mongo:/data/db mongo:6.0.7
.make/compiled-protocol-buffers: .make common/src/main/proto/*.proto
mkdir -p common/target/python
python -m grpc_tools.protoc \
-I common/src/main/proto \
--python_out=common/target/python \
--pyi_out=common/target/python \
--grpc_python_out=common/target/python \
common/src/main/proto/*.proto
# protoc --proto_path=common/src/main/proto \
# --python_out=common/target/python \
# --pyi_out=common/target/python \
# --grpc_python_out=common/target/python \
# common/src/main/proto/*.proto
@touch $@
.PHONY: compile-protocol-buffers
compile-protocol-buffers: .make/compiled-protocol-buffers
current_branch=$(shell git branch --show-current)
.PHONY: git-pull
git-pull:
git checkout main && git pull
@echo
git checkout develop && git merge main && git push
@echo
git checkout $(current_branch)
.PHONY: help
help:
@echo "make-tools for $(TAG)"
@echo
@echo "Please use \`make <target>', where <target> is one of:"
@echo " git-pull - to pull git changes from the main branch ( + update the develop branch)"
@echo " tests - to test the project"
@echo " clean - to remove generated files"
@echo " compile-protocol-buffers - to compile all .proto files"
@echo " install-client - to install the client code in the local maven repository"
@echo
@echo " build - to test and build the project"
@echo " build-server - to test and build just the server"
@echo " build-client - to test and build just the client"
@echo
@echo " start-mongodb - to start a local mongodb"
@echo " run-server-with-auth - to start the server app with authorization on"
@echo " run-server-without-auth - to start the server app with authorization off"
@echo " run-env - to run the annorepo env command"
@echo
@echo " docker-run - to start the server app in docker"
@echo " docker-stop - to stop the server app in docker"
@echo
@echo " docker-image - to build the docker image of the app"
@echo " push - to push the linux/amd64 docker image to registry.diginfra.net"
@echo
@echo " version-update - to update the project version"
@echo " dokka - to generate dokka html"
@echo " deploy - to deploy annorepo-client and annorepo-common"
@echo " release - to create a new release on github + deploy the new client"
@echo