-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Makefile
141 lines (125 loc) · 4.41 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
SHELL := env ORCHID_DIAGNOSE=$(ORCHID_DIAGNOSE) $(SHELL)
ORCHID_DIAGNOSE ?= false
.SHELLFLAGS := -ec
.DEFAULT_GOAL := help
# https://stackoverflow.com/a/10858332
# Check that given variables are set and all have non-empty values,
# die with an error otherwise.
#
# Params:
# 1. Variable name(s) to test.
# 2. (optional) Error message to print.
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))))
# use java 17 to build because 'org.graalvm.buildtools.native' in cli-bot requires java version >= 11
# both the libs and the cli app use java toolchains and will be built with java compatibility of version 8
__java_version_ok := $(shell java -version 2>&1|grep '17.0' >/dev/null; printf $$?)
.PHONY: check_java
check_java: ## check current java version (mostly used in other targets)
ifneq ($(__java_version_ok),$(shell echo 0))
$(error "Expected java 17")
endif
.PHONY: deploy-docs
deploy-docs: ## deploys documentation with orchid
cd docs; \
sed -i 's/^\s\sbaseUrl:\shttp:\/\/localhost:8080/ baseUrl: https:\/\/serpro69.github.io\/kotlin-faker/' ./src/orchid/resources/config.yml; \
sed -i 's/^\s\shomePageOnly:.*/#/' ./src/orchid/resources/config.yml; \
./gradlew orchidDeploy -PorchidEnvironment=prod -PorchidDiagnose=$(ORCHID_DIAGNOSE); \
git checkout ./src/orchid/resources/config.yml
.PHONY: snapshot-minor
snapshot-minor: ## publishes next snapshot with a minor version bump
./gradlew clean test integrationTest
./gradlew nativeCompile
./gradlew publishToSonatype --info
.PHONY: pre-release-major
pre-release-major: ## publishes next pre-release version with a major version bump
./gradlew test integrationTest \
nativeCompile \
publishToSonatype \
closeSonatypeStagingRepository \
tag \
-Prelease -PpreRelease -Pincrement=major \
--info
.PHONY: pre-release-minor
pre-release-minor: ## publishes next pre-release with a minor version bump
./gradlew test integrationTest \
nativeCompile \
publishToSonatype \
closeSonatypeStagingRepository \
tag \
-Prelease -PpreRelease -Pincrement=minor \
--info
.PHONY: pre-release-patch
pre-release-patch: ## publishes next pre-release with a patch version bump
./gradlew test integrationTest \
nativeCompile \
publishToSonatype \
closeSonatypeStagingRepository \
tag \
-Prelease -PpreRelease -Pincrement=patch \
--info
.PHONY: next-pre-release
next-pre-release: ## publishes next pre-release version
./gradlew test integrationTest \
nativeCompile \
publishToSonatype \
closeSonatypeStagingRepository \
tag \
-Prelease -Pincrement=pre_release \
--info
.PHONY: promote-to-release
promote-to-release: ## publishes next release from the current pre-release version
./gradlew test integrationTest \
nativeCompile \
publishToSonatype \
closeSonatypeStagingRepository \
tag \
-Prelease -PpromoteRelease \
--info
.PHONY: release-major
release-major: ## publishes next major release version
./gradlew test integrationTest \
nativeCompile \
publishToSonatype \
closeSonatypeStagingRepository \
tag \
-Prelease -Pincrement=major \
--info
.PHONY: release-minor
release-minor: ## publishes next minor release version
./gradlew test integrationTest \
tag \
nativeCompile \
publishToSonatype \
closeSonatypeStagingRepository \
-Prelease -Pincrement=minor \
--info
.PHONY: release-patch
release-patch: ## publishes next patch release version
./gradlew test integrationTest \
nativeCompile \
publishToSonatype \
closeSonatypeStagingRepository \
tag \
-Prelease -Pincrement=patch \
--info
.PHONY: release
release: check_java ## publishes the next release with a specified VERSION
@:$(call check_defined, VERSION, semantic version string - 'X.Y.Z(-rc.\d+)?')
# run tests
./gradlew test integrationTest -Pversion=$(VERSION)
# build and test native image
./gradlew nativeCompile -Pversion=$(VERSION) --info
./cli-bot/build/native/nativeCompile/faker-bot_$(VERSION) list --verbose >/dev/null || false
./cli-bot/build/native/nativeCompile/faker-bot_$(VERSION) lookup a --verbose >/dev/null || false
# publish to sonatype and close staging repo
./gradlew publishToSonatype closeSonatypeStagingRepository -Pversion=$(VERSION) --info
# create and push git tag
git tag v$(VERSION)
.PHONY: help
help: ## Displays this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'