1212# assemble <VERSION> : build client artifacts with version
1313# bump <VERSION> : bump client internals to version
1414# bumpmatrix <VERSION> : bump stack version in test matrix to version
15- # codegen : generate endpoints
15+ # codegen <VERSION> : generate endpoints
1616# docsgen <VERSION> : generate documentation
1717# examplegen : generate the doc examples
1818# clean : clean workspace
2424# ------------------------------------------------------- #
2525script_path=$( dirname " $( realpath -s " $0 " ) " )
2626repo=$( realpath " $script_path /../" )
27- generator=$( realpath " $script_path /../../elastic-client-generator-js" )
2827
2928# shellcheck disable=SC1090
3029CMD=$1
@@ -38,7 +37,6 @@ product="elastic/elasticsearch-js"
3837output_folder=" .ci/output"
3938codegen_folder=" .ci/output"
4039OUTPUT_DIR=" $repo /${output_folder} "
41- # REPO_BINDING="${OUTPUT_DIR}:/sln/${output_folder}"
4240NODE_JS_VERSION=18
4341WORKFLOW=${WORKFLOW-staging}
4442mkdir -p " $OUTPUT_DIR "
@@ -59,18 +57,29 @@ case $CMD in
5957 echo -e " \033[31;1mTARGET: assemble -> missing version parameter\033[0m"
6058 exit 1
6159 fi
62- echo -e " \033[36;1mTARGET: assemble artefact $VERSION \033[0m"
60+ echo -e " \033[36;1mTARGET: assemble artifact $VERSION \033[0m"
6361 TASK=release
6462 TASK_ARGS=(" $VERSION " " $output_folder " )
6563 ;;
6664 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
7075 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+
7282 TASK=codegen
73- # VERSION is BRANCH here for now
7483 TASK_ARGS=(" $VERSION " )
7584 ;;
7685 docsgen)
@@ -80,13 +89,11 @@ case $CMD in
8089 fi
8190 echo -e " \033[36;1mTARGET: generate docs for $VERSION \033[0m"
8291 TASK=codegen
83- # VERSION is BRANCH here for now
8492 TASK_ARGS=(" $VERSION " " $codegen_folder " )
8593 ;;
8694 examplesgen)
8795 echo -e " \033[36;1mTARGET: generate examples\033[0m"
8896 TASK=codegen
89- # VERSION is BRANCH here for now
9097 TASK_ARGS=(" $VERSION " " $codegen_folder " )
9198 ;;
9299 bump)
@@ -96,7 +103,6 @@ case $CMD in
96103 fi
97104 echo -e " \033[36;1mTARGET: bump to version $VERSION \033[0m"
98105 TASK=bump
99- # VERSION is BRANCH here for now
100106 TASK_ARGS=(" $VERSION " )
101107 ;;
102108 bumpmatrix)
@@ -128,6 +134,8 @@ docker build \
128134 --file .ci/Dockerfile \
129135 --tag " $product " \
130136 --build-arg NODE_JS_VERSION=" $NODE_JS_VERSION " \
137+ --build-arg " BUILDER_UID=$( id -u) " \
138+ --build-arg " BUILDER_GID=$( id -g) " \
131139 .
132140
133141# ------------------------------------------------------- #
@@ -137,15 +145,18 @@ docker build \
137145echo -e " \033[34;1mINFO: running $product container\033[0m"
138146
139147docker 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 \
143150 -u " $( id -u) :$( id -g) " \
144151 --env " WORKFLOW=$WORKFLOW " \
145152 --name make-elasticsearch-js \
146153 --rm \
147154 $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[*]} "
149160
150161# ------------------------------------------------------- #
151162# Post Command tasks & checks
0 commit comments