-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
119 lines (94 loc) · 2.72 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
export DOCKER_TAG_NAME := savantly/nexus-command
export PROJECT_ROOT := $(shell pwd)
VERSION := $(shell mvn -q \
-Dexec.executable=echo \
-Dexec.args='$${project.version}' \
--non-recursive \
exec:exec)
# Strip the -SNAPSHOT suffix
VERSION := $(shell echo $(VERSION) | sed 's/-SNAPSHOT//')
TAGGED_VERSION := $(VERSION)
NEXT_VERSION := $(shell echo $(VERSION) | awk -F. '{$$NF = $$NF + 1;} 1' | sed 's/ /./g')
GIT_COMMIT := $(shell git rev-parse --short HEAD)
.PHONY: get-version
get-version:
@echo $(VERSION)
.PHONY: dev
dev:
$(call setup_env, .env)
@echo "Running the program"
./mvnw install -DskipTests -U
./mvnw -pl webapp spring-boot:run
.PHONY: test-docker
test-docker: build-image
$(call setup_env, .env)
@echo "Running the program"
docker compose -f docker-compose.yml up
.PHONY: dev-docker
dev-docker:
$(call setup_env, .env)
@echo "Running the program"
docker compose -f docker-compose.dev.yml up
.PHONY: start-kafka
start-kafka:
@echo "Running the program"
docker compose -f docker-compose.kafka.yml up
.PHONY: test
test:
@echo "Running the tests"
./mvnw test integration-test
.PHONY: clean
clean:
@echo "Cleaning the project"
./mvnw clean
.PHONY: build-image
build-image:
@echo "Building the project"
./mvnw install -DskipTests
docker build \
-f docker/Dockerfile \
-t ${DOCKER_TAG_NAME}:${VERSION} \
-t ${DOCKER_TAG_NAME}:latest \
.
.PHONY: push-image
docker push ${DOCKER_TAG_NAME}:${VERSION}
.PHONY: run-image
run-image:
docker compose up
.PHONY: run-image-postgres
run-image-postgres:
docker compose -f docker-compose.postgres.yml up
.PHONY: ensure-git-repo-pristine
ensure-git-repo-pristine:
@echo "Ensuring git repo is pristine"
@[[ $(shell git status --porcelain=v1 2>/dev/null | wc -l) -gt 0 ]] && echo "Git repo is not pristine" && exit 1 || echo "Git repo is pristine"
.PHONY: bump-version
bump-version:
@echo "Bumping version to $(NEXT_VERSION)"
./mvnw versions:set -DnewVersion=$(NEXT_VERSION)-SNAPSHOT
./mvnw versions:commit
git add * || true
git commit -m "Prepared for $(NEXT_VERSION)"
.PHONY: tag-version
tag-version:
@echo "Preparing release..."
@echo "Version: $(VERSION)"
@echo "Commit: $(GIT_COMMIT)"
@echo "Image Tag: $(IMAGE_TAG)"
./mvnw versions:set -DnewVersion=$(VERSION)
./mvnw versions:commit
git add * || true
git commit -m "Published $(VERSION)"
git tag -a $(TAGGED_VERSION) -m "Release $(VERSION)"
git push origin $(TAGGED_VERSION)
@echo "Tag $(TAGGED_VERSION) created and pushed to origin"
.PHONY: release
release: ensure-git-repo-pristine tag-version bump-version
git push
@echo "Release $(VERSION) completed and pushed to origin"
define setup_env
$(eval ENV_FILE := $(1))
@echo " - setup env $(ENV_FILE)"
$(eval include $(1))
$(eval export)
endef