Skip to content

Commit 57b826b

Browse files
authored
Add build script to query insights plugin (#14)
Signed-off-by: Chenyang Ji <cyji@amazon.com>
1 parent b654c05 commit 57b826b

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

scripts/build.sh

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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+
function usage() {
13+
echo "Usage: $0 [args]"
14+
echo ""
15+
echo "Arguments:"
16+
echo -e "-v VERSION\t[Required] OpenSearch version."
17+
echo -e "-q QUALIFIER\t[Optional] Version qualifier."
18+
echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'."
19+
echo -e "-p PLATFORM\t[Optional] Platform, ignored."
20+
echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored."
21+
echo -e "-o OUTPUT\t[Optional] Output path, default is 'artifacts'."
22+
echo -e "-h help"
23+
}
24+
25+
while getopts ":h:v:q:s:o:p:a:" arg; do
26+
case $arg in
27+
h)
28+
usage
29+
exit 1
30+
;;
31+
v)
32+
VERSION=$OPTARG
33+
;;
34+
q)
35+
QUALIFIER=$OPTARG
36+
;;
37+
s)
38+
SNAPSHOT=$OPTARG
39+
;;
40+
o)
41+
OUTPUT=$OPTARG
42+
;;
43+
p)
44+
PLATFORM=$OPTARG
45+
;;
46+
a)
47+
ARCHITECTURE=$OPTARG
48+
;;
49+
:)
50+
echo "Error: -${OPTARG} requires an argument"
51+
usage
52+
exit 1
53+
;;
54+
?)
55+
echo "Invalid option: -${arg}"
56+
exit 1
57+
;;
58+
esac
59+
done
60+
61+
if [ -z "$VERSION" ]; then
62+
echo "Error: You must specify the OpenSearch version"
63+
usage
64+
exit 1
65+
fi
66+
67+
[[ ! -z "$QUALIFIER" ]] && VERSION=$VERSION-$QUALIFIER
68+
[[ "$SNAPSHOT" == "true" ]] && VERSION=$VERSION-SNAPSHOT
69+
[ -z "$OUTPUT" ] && OUTPUT=artifacts
70+
71+
mkdir -p $OUTPUT
72+
73+
./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
74+
75+
zipPath=$(find . -path \*build/distributions/*.zip)
76+
distributions="$(dirname "${zipPath}")"
77+
78+
echo "COPY ${distributions}/*.zip"
79+
mkdir -p $OUTPUT/plugins
80+
cp ${distributions}/*.zip ./$OUTPUT/plugins
81+
82+
# Publish plugin zips to maven
83+
./gradlew publishPluginZipPublicationToMavenLocal -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
84+
./gradlew publishPluginZipPublicationToZipStagingRepository -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
85+
mkdir -p $OUTPUT/maven/org/opensearch
86+
cp -r ./build/local-staging-repo/org/opensearch/. $OUTPUT/maven/org/opensearch

0 commit comments

Comments
 (0)