12
12
# assemble <VERSION> : build client artifacts with version
13
13
# bump <VERSION> : bump client internals to version
14
14
# bumpmatrix <VERSION> : bump stack version in test matrix to version
15
- # codegen : generate endpoints
15
+ # codegen <VERSION> : generate endpoints
16
16
# docsgen <VERSION> : generate documentation
17
17
# examplegen : generate the doc examples
18
18
# clean : clean workspace
24
24
# ------------------------------------------------------- #
25
25
script_path=$( dirname " $( realpath -s " $0 " ) " )
26
26
repo=$( realpath " $script_path /../" )
27
- generator=$( realpath " $script_path /../../elastic-client-generator-js" )
28
27
29
28
# shellcheck disable=SC1090
30
29
CMD=$1
@@ -38,7 +37,6 @@ product="elastic/elasticsearch-js"
38
37
output_folder=" .ci/output"
39
38
codegen_folder=" .ci/output"
40
39
OUTPUT_DIR=" $repo /${output_folder} "
41
- # REPO_BINDING="${OUTPUT_DIR}:/sln/${output_folder}"
42
40
NODE_JS_VERSION=18
43
41
WORKFLOW=${WORKFLOW-staging}
44
42
mkdir -p " $OUTPUT_DIR "
@@ -59,18 +57,29 @@ case $CMD in
59
57
echo -e " \033[31;1mTARGET: assemble -> missing version parameter\033[0m"
60
58
exit 1
61
59
fi
62
- echo -e " \033[36;1mTARGET: assemble artefact $VERSION \033[0m"
60
+ echo -e " \033[36;1mTARGET: assemble artifact $VERSION \033[0m"
63
61
TASK=release
64
62
TASK_ARGS=(" $VERSION " " $output_folder " )
65
63
;;
66
64
codegen)
67
- if [ -v $VERSION ]; then
68
- echo -e " \033[31;1mTARGET: codegen -> missing version parameter\033[0m"
69
- exit 1
65
+ if [ -v " $VERSION " ] || [[ -z " $VERSION " ]]; then
66
+ # fall back to branch name or `main` if no VERSION is set
67
+ branch_name=$( git rev-parse --abbrev-ref HEAD)
68
+ if [[ " $branch_name " =~ ^\d +\.\d + ]]; then
69
+ echo -e " \033[36;1mTARGET: codegen -> No VERSION found, using branch name: \` $VERSION \` \033[0m"
70
+ VERSION=" $branch_name "
71
+ else
72
+ echo -e " \033[36;1mTARGET: codegen -> No VERSION found, using \` main\` \033[0m"
73
+ VERSION=" main"
74
+ fi
70
75
fi
71
- echo -e " \033[36;1mTARGET: codegen API v$VERSION \033[0m"
76
+ if [ " $VERSION " = ' main' ]; then
77
+ echo -e " \033[36;1mTARGET: codegen API $VERSION \033[0m"
78
+ else
79
+ echo -e " \033[36;1mTARGET: codegen API v$VERSION \033[0m"
80
+ fi
81
+
72
82
TASK=codegen
73
- # VERSION is BRANCH here for now
74
83
TASK_ARGS=(" $VERSION " )
75
84
;;
76
85
docsgen)
@@ -80,13 +89,11 @@ case $CMD in
80
89
fi
81
90
echo -e " \033[36;1mTARGET: generate docs for $VERSION \033[0m"
82
91
TASK=codegen
83
- # VERSION is BRANCH here for now
84
92
TASK_ARGS=(" $VERSION " " $codegen_folder " )
85
93
;;
86
94
examplesgen)
87
95
echo -e " \033[36;1mTARGET: generate examples\033[0m"
88
96
TASK=codegen
89
- # VERSION is BRANCH here for now
90
97
TASK_ARGS=(" $VERSION " " $codegen_folder " )
91
98
;;
92
99
bump)
@@ -96,7 +103,6 @@ case $CMD in
96
103
fi
97
104
echo -e " \033[36;1mTARGET: bump to version $VERSION \033[0m"
98
105
TASK=bump
99
- # VERSION is BRANCH here for now
100
106
TASK_ARGS=(" $VERSION " )
101
107
;;
102
108
bumpmatrix)
@@ -128,6 +134,8 @@ docker build \
128
134
--file .ci/Dockerfile \
129
135
--tag " $product " \
130
136
--build-arg NODE_JS_VERSION=" $NODE_JS_VERSION " \
137
+ --build-arg " BUILDER_UID=$( id -u) " \
138
+ --build-arg " BUILDER_GID=$( id -g) " \
131
139
.
132
140
133
141
# ------------------------------------------------------- #
@@ -137,15 +145,18 @@ docker build \
137
145
echo -e " \033[34;1mINFO: running $product container\033[0m"
138
146
139
147
docker run \
140
- --volume " $repo :/usr/src/app" \
141
- --volume " $generator :/usr/src/elastic-client-generator-js" \
142
- --volume /usr/src/app/node_modules \
148
+ --volume " $repo :/usr/src/elasticsearch-js" \
149
+ --volume /usr/src/elasticsearch-js/node_modules \
143
150
-u " $( id -u) :$( id -g) " \
144
151
--env " WORKFLOW=$WORKFLOW " \
145
152
--name make-elasticsearch-js \
146
153
--rm \
147
154
$product \
148
- node .ci/make.mjs --task $TASK ${TASK_ARGS[*]}
155
+ /bin/bash -c " cd /usr/src && \
156
+ git clone https://$CLIENTS_GITHUB_TOKEN @github.com/elastic/elastic-client-generator-js.git && \
157
+ mkdir -p /usr/src/elastic-client-generator-js/output && \
158
+ cd /usr/src/elasticsearch-js && \
159
+ node .ci/make.mjs --task $TASK ${TASK_ARGS[*]} "
149
160
150
161
# ------------------------------------------------------- #
151
162
# Post Command tasks & checks
0 commit comments