-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add build script #21
Closed
Closed
Add build script #21
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/bin/bash | ||
|
||
# Copyright OpenSearch Contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# The OpenSearch Contributors require contributions made to | ||
# this file be licensed under the Apache-2.0 license or a | ||
# compatible open source license. | ||
|
||
set -ex | ||
|
||
function usage() { | ||
echo "Usage: $0 [args]" | ||
echo "" | ||
echo "Arguments:" | ||
echo -e "-v VERSION\t[Required] OpenSearch version." | ||
echo -e "-q QUALIFIER\t[Optional] Version qualifier." | ||
echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'." | ||
echo -e "-p PLATFORM\t[Optional] Platform, default is 'uname -s'." | ||
echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored." | ||
echo -e "-o OUTPUT\t[Optional] Output path, default is 'artifacts'." | ||
echo -e "-h help" | ||
} | ||
|
||
while getopts ":h:v:q:s:o:p:a:" arg; do | ||
case $arg in | ||
h) | ||
usage | ||
exit 1 | ||
;; | ||
v) | ||
VERSION=$OPTARG | ||
;; | ||
q) | ||
QUALIFIER=$OPTARG | ||
;; | ||
s) | ||
SNAPSHOT=$OPTARG | ||
;; | ||
o) | ||
OUTPUT=$OPTARG | ||
;; | ||
p) | ||
PLATFORM=$OPTARG | ||
;; | ||
a) | ||
ARCHITECTURE=$OPTARG | ||
;; | ||
:) | ||
echo "Error: -${OPTARG} requires an argument" | ||
usage | ||
exit 1 | ||
;; | ||
?) | ||
echo "Invalid option: -${arg}" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [ -z "$VERSION" ]; then | ||
echo "Error: You must specify the OpenSearch Dashboards version" | ||
usage | ||
exit 1 | ||
fi | ||
|
||
[ -z "$OUTPUT" ] && OUTPUT=artifacts | ||
[ -z "$PLATFORM" ] && PLATFORM=$(uname -s | awk '{print tolower($0)}') | ||
[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER" | ||
|
||
NVM_CMD="source $NVM_DIR/nvm.sh && nvm use" | ||
if [ "$PLATFORM" = "windows" ]; then | ||
NVM_CMD="volta install node@`cat ../../OpenSearch-Dashboards/.nvmrc` && volta install yarn@`jq -r '.engines.yarn' ../../OpenSearch-Dashboards/package.json`" | ||
fi | ||
|
||
MINOR_VERSION=${VERSION%.*} | ||
git clone --branch $MINOR_VERSION --single-branch https://github.com/opensearch-project/OpenSearch-Dashboards ../../OpenSearch-Dashboards || echo repo exists | ||
mkdir -p ../../OpenSearch-Dashboards/plugins | ||
|
||
mkdir -p $OUTPUT/plugins | ||
# For hybrid plugin it actually resides in 'reportsDashboards/dashboards-reports' | ||
PLUGIN_FOLDER=$(basename "$PWD") | ||
PLUGIN_NAME=$(basename $(dirname "$PWD")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is |
||
# TODO: [CLEANUP] Needed OpenSearch Dashboards git repo to build the required modules for plugins | ||
# This makes it so there is a dependency on having Dashboards pulled already. | ||
cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins | ||
echo "BUILD MODULES FOR $PLUGIN_NAME" | ||
(cd ../../OpenSearch-Dashboards && eval $NVM_CMD && yarn osd bootstrap) | ||
echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" | ||
(cd ../../OpenSearch-Dashboards && eval $NVM_CMD && cd plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) | ||
ZIP_NAME=`ls ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build | grep .zip` | ||
unzip ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$ZIP_NAME -d ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/ | ||
echo "COPY $PLUGIN_NAME.zip" | ||
cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/ | ||
rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is no longer true