Skip to content

Commit 5637d42

Browse files
committed
copy build.sh over from opensearch-build (opensearch-project#4887)
the build script should be located in this repository instead of centrally in [opensearch-build][] to allow per-branch specific builds (newer versions might have newer requirements, which currently cannot be reflected). the file was copied 1:1 from `scripts/components/OpenSearch/build.sh` as of commit 9e1aa38 in the [opensearch-build][] repository. this is part of opensearch-build#99 and needs to be backported to all active branches because the file here will only be used by the build once the central one in opensearch-build has been removed which in turn can only happen when all active branches have the `build.sh`. [opensearch-build]: https://github.com/opensearch-project/opensearch-build Signed-off-by: Ralph Ursprung <Ralph.Ursprung@avaloq.com> Signed-off-by: Ralph Ursprung <Ralph.Ursprung@avaloq.com> (cherry picked from commit e357246)
1 parent 6d5b6fd commit 5637d42

File tree

2 files changed

+163
-0
lines changed

2 files changed

+163
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1111
- Support for HTTP/2 (server-side) ([#3847](https://github.com/opensearch-project/OpenSearch/pull/3847))
1212
- BWC version 2.2.2 ([#4383](https://github.com/opensearch-project/OpenSearch/pull/4383))
1313
- Support for labels on version bump PRs, skip label support for changelog verifier ([#4391](https://github.com/opensearch-project/OpenSearch/pull/4391))
14+
- Copy `build.sh` over from opensearch-build ([#4887](https://github.com/opensearch-project/OpenSearch/pull/4887))
15+
1416
### Dependencies
1517
- Bumps `com.diffplug.spotless` from 6.9.1 to 6.10.0
1618
- Bumps `xmlbeans` from 5.1.0 to 5.1.1

scripts/build.sh

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
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, default is 'uname -s'."
20+
echo -e "-a ARCHITECTURE\t[Optional] Build architecture, default is 'uname -m'."
21+
echo -e "-d DISTRIBUTION\t[Optional] Distribution, default is 'tar'."
22+
echo -e "-o OUTPUT\t[Optional] Output path, default is 'artifacts'."
23+
echo -e "-h help"
24+
}
25+
26+
while getopts ":h:v:q:s:o:p:a:d:" arg; do
27+
case $arg in
28+
h)
29+
usage
30+
exit 1
31+
;;
32+
v)
33+
VERSION=$OPTARG
34+
;;
35+
q)
36+
QUALIFIER=$OPTARG
37+
;;
38+
s)
39+
SNAPSHOT=$OPTARG
40+
;;
41+
o)
42+
OUTPUT=$OPTARG
43+
;;
44+
p)
45+
PLATFORM=$OPTARG
46+
;;
47+
a)
48+
ARCHITECTURE=$OPTARG
49+
;;
50+
d)
51+
DISTRIBUTION=$OPTARG
52+
;;
53+
:)
54+
echo "Error: -${OPTARG} requires an argument"
55+
usage
56+
exit 1
57+
;;
58+
?)
59+
echo "Invalid option: -${arg}"
60+
exit 1
61+
;;
62+
esac
63+
done
64+
65+
if [ -z "$VERSION" ]; then
66+
echo "Error: You must specify the OpenSearch version"
67+
usage
68+
exit 1
69+
fi
70+
71+
[ -z "$OUTPUT" ] && OUTPUT=artifacts
72+
73+
mkdir -p $OUTPUT/maven/org/opensearch
74+
75+
# Build project and publish to maven local.
76+
./gradlew publishToMavenLocal -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
77+
78+
# Publish to existing test repo, using this to stage release versions of the artifacts that can be released from the same build.
79+
./gradlew publishNebulaPublicationToTestRepository -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
80+
81+
# Copy maven publications to be promoted
82+
cp -r ./build/local-test-repo/org/opensearch "${OUTPUT}"/maven/org
83+
84+
# Assemble distribution artifact
85+
# see https://github.com/opensearch-project/OpenSearch/blob/main/settings.gradle#L34 for other distribution targets
86+
87+
[ -z "$PLATFORM" ] && PLATFORM=$(uname -s | awk '{print tolower($0)}')
88+
[ -z "$ARCHITECTURE" ] && ARCHITECTURE=`uname -m`
89+
[ -z "$DISTRIBUTION" ] && DISTRIBUTION="tar"
90+
91+
case $PLATFORM-$DISTRIBUTION-$ARCHITECTURE in
92+
linux-tar-x64|darwin-tar-x64)
93+
PACKAGE="tar"
94+
EXT="tar.gz"
95+
TYPE="archives"
96+
TARGET="$PLATFORM-$PACKAGE"
97+
SUFFIX="$PLATFORM-x64"
98+
;;
99+
linux-tar-arm64|darwin-tar-arm64)
100+
PACKAGE="tar"
101+
EXT="tar.gz"
102+
TYPE="archives"
103+
TARGET="$PLATFORM-arm64-$PACKAGE"
104+
SUFFIX="$PLATFORM-arm64"
105+
;;
106+
linux-rpm-x64)
107+
PACKAGE="rpm"
108+
EXT="rpm"
109+
TYPE="packages"
110+
TARGET="rpm"
111+
SUFFIX="x86_64"
112+
;;
113+
linux-rpm-arm64)
114+
PACKAGE="rpm"
115+
EXT="rpm"
116+
TYPE="packages"
117+
TARGET="arm64-rpm"
118+
SUFFIX="aarch64"
119+
;;
120+
windows-zip-x64)
121+
PACKAGE="zip"
122+
EXT="zip"
123+
TYPE="archives"
124+
TARGET="$PLATFORM-$PACKAGE"
125+
SUFFIX="$PLATFORM-x64"
126+
;;
127+
windows-zip-arm64)
128+
PACKAGE="zip"
129+
EXT="zip"
130+
TYPE="archives"
131+
TARGET="$PLATFORM-arm64-$PACKAGE"
132+
SUFFIX="$PLATFORM-arm64"
133+
;;
134+
*)
135+
echo "Unsupported platform-distribution-architecture combination: $PLATFORM-$DISTRIBUTION-$ARCHITECTURE"
136+
exit 1
137+
;;
138+
esac
139+
140+
echo "Building OpenSearch for $PLATFORM-$DISTRIBUTION-$ARCHITECTURE"
141+
142+
./gradlew :distribution:$TYPE:$TARGET:assemble -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
143+
144+
# Copy artifact to dist folder in bundle build output
145+
[[ "$SNAPSHOT" == "true" ]] && IDENTIFIER="-SNAPSHOT"
146+
ARTIFACT_BUILD_NAME=`ls distribution/$TYPE/$TARGET/build/distributions/ | grep "opensearch-min.*$SUFFIX.$EXT"`
147+
mkdir -p "${OUTPUT}/dist"
148+
cp distribution/$TYPE/$TARGET/build/distributions/$ARTIFACT_BUILD_NAME "${OUTPUT}"/dist/$ARTIFACT_BUILD_NAME
149+
150+
echo "Building core plugins..."
151+
mkdir -p "${OUTPUT}/core-plugins"
152+
cd plugins
153+
../gradlew assemble -Dbuild.snapshot="$SNAPSHOT" -Dbuild.version_qualifier=$QUALIFIER
154+
cd ..
155+
for plugin in plugins/*; do
156+
PLUGIN_NAME=$(basename "$plugin")
157+
if [ -d "$plugin" ] && [ "examples" != "$PLUGIN_NAME" ]; then
158+
PLUGIN_ARTIFACT_BUILD_NAME=`ls "$plugin"/build/distributions/ | grep "$PLUGIN_NAME.*$IDENTIFIER.zip"`
159+
cp "$plugin"/build/distributions/"$PLUGIN_ARTIFACT_BUILD_NAME" "${OUTPUT}"/core-plugins/"$PLUGIN_ARTIFACT_BUILD_NAME"
160+
fi
161+
done

0 commit comments

Comments
 (0)