Skip to content

Commit ba6f3e2

Browse files
derek-hogithub-actions[bot]
authored andcommitted
Add custom build script to support different cypress version (#2027)
Signed-off-by: Derek Ho <dxho@amazon.com> (cherry picked from commit e35f7f7)
1 parent a9caae9 commit ba6f3e2

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

scripts/build.sh

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

0 commit comments

Comments
 (0)