-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
41 lines (33 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
MVNCMD := mvn -B ${MVNARGS}
POSTRUN := rm -rf .testcontainers*
CLEANUP := rc=$$?; $(POSTRUN); exit $$rc
TAG := latest
# handle release args
ifeq (release,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "release"
RELEASE_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(RELEASE_ARGS):;@:)
endif
all: package
package:
$(MVNCMD) package; $(CLEANUP)
clean:
$(MVNCMD) clean; $(CLEANUP)
dbtest: .dbtest.done
release:
$(eval SHELL := /bin/bash)
git remote update
if git show-branch *master | grep -A 1 '^--$$' | grep -q remotes; then\
echo Your local repository is not up to date; exit 1;\
fi
$(eval CURRENT_VERSION := $(shell xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' pom.xml))
$(eval VERSION := $(if $(RELEASE_ARGS),$(RELEASE_ARGS),$(subst -SNAPSHOT,,$(CURRENT_VERSION))))
git flow release start "$(VERSION)"
perl -pi -e 's,<version>$(CURRENT_VERSION)</version>,<version>'"$(VERSION)"'</version>,' pom.xml
git commit pom.xml -m "bump release to $(VERSION)"
git flow release finish -m "release $(VERSION)" </dev/null
perl -pi -e 'BEGIN{sub bump{@v=split(/\./,$$_[0]);join(".",@v[0..1]).".".($$v[-1]+1);}}s,<version>($(VERSION))</version>,"<version>".(bump($$1))."-SNAPSHOT</version>",e' pom.xml
git commit pom.xml -m "develop back to snapshot mode"
push:
git push --all && git push --tags