Skip to content

Commit b307dd6

Browse files
authored
Merge branch 'main' into release-ftr-tests
2 parents e23196a + 757f4ce commit b307dd6

File tree

2 files changed

+106
-1
lines changed

2 files changed

+106
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@
5353
"ejs": "^3.1.10",
5454
"express": "^4.19.2"
5555
}
56-
}
56+
}

scripts/build.sh

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/bin/bash
2+
3+
# Copyright OpenSearch Contributors
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# The OpenSearch Contributors require contributions made to
7+
# this file be licensed under the Apache-2.0 license or a
8+
# compatible open source license.
9+
10+
set -ex
11+
12+
# vars / libs
13+
PLUGIN_NAME=$(basename "$PWD")
14+
PLUGIN_PATH=`realpath ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME`
15+
16+
function usage() {
17+
echo "Usage: $0 [args]"
18+
echo ""
19+
echo "Arguments:"
20+
echo -e "-v VERSION\t[Required] OpenSearch version."
21+
echo -e "-q QUALIFIER\t[Optional] Version qualifier."
22+
echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'."
23+
echo -e "-p PLATFORM\t[Optional] Platform, ignored."
24+
echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored."
25+
echo -e "-o OUTPUT\t[Optional] Output path, default is 'artifacts'."
26+
echo -e "-h help"
27+
}
28+
29+
30+
function cleanup_all() {
31+
rm -rf -- $PLUGIN_PATH
32+
}
33+
34+
trap cleanup_all TERM INT EXIT
35+
36+
while getopts ":h:v:q:s:o:p:a:" arg; do
37+
case $arg in
38+
h)
39+
usage
40+
exit 1
41+
;;
42+
v)
43+
VERSION=$OPTARG
44+
;;
45+
q)
46+
QUALIFIER=$OPTARG
47+
;;
48+
s)
49+
SNAPSHOT=$OPTARG
50+
;;
51+
o)
52+
OUTPUT=$OPTARG
53+
;;
54+
p)
55+
PLATFORM=$OPTARG
56+
;;
57+
a)
58+
ARCHITECTURE=$OPTARG
59+
;;
60+
:)
61+
echo "Error: -${OPTARG} requires an argument"
62+
usage
63+
exit 1
64+
;;
65+
?)
66+
echo "Invalid option: -${arg}"
67+
exit 1
68+
;;
69+
esac
70+
done
71+
72+
if [ -z "$VERSION" ]; then
73+
echo "Error: You must specify the OpenSearch Dashboards version"
74+
usage
75+
exit 1
76+
fi
77+
78+
[ -z "$OUTPUT" ] && OUTPUT=artifacts
79+
[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER"
80+
81+
NVM_CMD="source $NVM_DIR/nvm.sh && nvm use"
82+
if [ "$PLATFORM" = "windows" ]; then
83+
NVM_CMD="volta install node@`cat ../OpenSearch-Dashboards/.nvmrc` && volta install yarn@`jq -r '.engines.yarn' ../OpenSearch-Dashboards/package.json`"
84+
fi
85+
86+
HELPER_CMD=$(jq -r '.scripts.plugin_helpers' package.json)
87+
if [ "$HELPER_CMD" != null ]; then
88+
HELPER_STRING=plugin_helpers
89+
else
90+
HELPER_STRING=plugin-helpers
91+
fi
92+
93+
mkdir -p $OUTPUT/plugins
94+
# TODO: [CLEANUP] Needed OpenSearch Dashboards git repo to build the required modules for plugins
95+
# This makes it so there is a dependency on having Dashboards pulled already.
96+
cp -r ../$PLUGIN_NAME/ ../OpenSearch-Dashboards/plugins
97+
echo "BUILD MODULES FOR $PLUGIN_NAME"
98+
CURR_DIR=`pwd`
99+
# Bootstrap loose to allow different cypress version
100+
cd ../OpenSearch-Dashboards; eval $NVM_CMD; yarn osd bootstrap --single-version=loose
101+
echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME"
102+
cd plugins/$PLUGIN_NAME; yarn $HELPER_STRING build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER
103+
cd $CURR_DIR
104+
echo "COPY $PLUGIN_NAME.zip"
105+
cp -r ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/

0 commit comments

Comments
 (0)