Skip to content

Commit

Permalink
Update alerting with qualifier support in releases (opensearch-projec…
Browse files Browse the repository at this point in the history
…t#366)

* Update alerting with qualifier support in releases

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Move snapshot above

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Change to 2.0.0-SNAPSHOT until alerting fixed to compile on 2.0.0-alpha1-SNAPSHOT

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Support qualifier for docker file pulling

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
Signed-off-by: Angie Zhang <langelzh@amazon.com>
  • Loading branch information
peterzhuamazon authored and Angie Zhang committed Jun 29, 2022
1 parent d16bb4b commit 5246e77
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/multi-node-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
- name: Checkout Branch
uses: actions/checkout@v2
- name: Run integration tests with multi node config
run: ./gradlew integTest -PnumNodes=3 -Dopensearch.version=2.0.0-SNAPSHOT
run: ./gradlew integTest -PnumNodes=3
18 changes: 13 additions & 5 deletions .github/workflows/security-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,29 @@ jobs:
java-version: 11
- name: Build Alerting
# Only assembling since the full build is governed by other workflows
run: ./gradlew assemble -Dopensearch.version=2.0.0-SNAPSHOT
run: ./gradlew assemble
- name: Pull and Run Docker
run: |
plugin=`ls alerting/build/distributions/*.zip`
list_of_files=`ls`
list_of_all_files=`ls alerting/build/distributions/`
version=`echo $plugin|awk -F- '{print $3}'| cut -d. -f 1-3`
plugin_version=`echo $plugin|awk -F- '{print $3}'| cut -d. -f 1-4`
candidate_version=`echo $plugin|awk -F- '{print $4}'| cut -d. -f 1-1`
echo $version $plugin_version $candidate_version
qualifier=`echo $plugin|awk -F- '{print $4}'| cut -d. -f 1-1`
candidate_version=`echo $plugin|awk -F- '{print $5}'| cut -d. -f 1-1`
docker_version=$version-$qualifier-candidate_version
if [ -z $candidate_version ]; then
candidate_version=$qualifier && qualifier=""
docker_version=$version
fi
echo $version $plugin_version $qualifier $candidate_version $docker_version
echo $ls $list_of_all_files
if docker pull opensearchstaging/opensearch:$version
if docker pull opensearchstaging/opensearch:$docker_version
then
echo "FROM opensearchstaging/opensearch:$version" >> Dockerfile
echo "FROM opensearchstaging/opensearch:$docker_version" >> Dockerfile
echo "RUN if [ -d /usr/share/opensearch/plugins/opensearch-alerting ]; then /usr/share/opensearch/bin/opensearch-plugin remove opensearch-alerting; fi" >> Dockerfile
echo "ADD alerting/build/distributions/opensearch-alerting-$plugin_version-$candidate_version.zip /tmp/" >> Dockerfile
echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/opensearch-alerting-$plugin_version-$candidate_version.zip" >> Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
with:
java-version: ${{ matrix.java }}
- name: Build and run with Gradle
run: ./gradlew build -Dopensearch.version=2.0.0-SNAPSHOT
run: ./gradlew build
- name: Create Artifact Path
run: |
mkdir -p alerting-artifacts
Expand Down
22 changes: 12 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@ buildscript {

ext {
opensearch_version = System.getProperty("opensearch.version", "2.0.0-SNAPSHOT")
// 1.0.0 -> 1.0.0.0, and 1.0.0-SNAPSHOT -> 1.0.0.0-SNAPSHOT
opensearch_build = opensearch_version.replaceAll(/(\.\d)([^\d]*)$/, '$1.0$2')
buildVersionQualifier = System.getProperty("build.version_qualifier")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
// 2.0.0-alpha1-SNAPSHOT -> 2.0.0.0-alpha1-SNAPSHOT
version_tokens = opensearch_version.tokenize('-')
opensearch_build = version_tokens[0] + '.0'
if (buildVersionQualifier) {
opensearch_build += "-${buildVersionQualifier}"
}
if (isSnapshot) {
opensearch_build += "-SNAPSHOT"
}
common_utils_version = System.getProperty("common_utils.version", opensearch_build)
kotlin_version = '1.6.10'
}
Expand Down Expand Up @@ -63,16 +72,9 @@ task ktlintFormat(type: JavaExec, group: "formatting") {

check.dependsOn ktlint

ext {
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
}

allprojects {
group = "org.opensearch"
version = "${opensearch_version}" - "-SNAPSHOT" + ".0"
if (isSnapshot) {
version += "-SNAPSHOT"
}
version = "${opensearch_build}"

apply from: "$rootDir/build-tools/repositories.gradle"

Expand Down
11 changes: 8 additions & 3 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function usage() {
echo ""
echo "Arguments:"
echo -e "-v VERSION\t[Required] OpenSearch version."
echo -e "-q QUALIFIER\t[Optional] Build qualifier."
echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'."
echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored."
echo -e "-p PLATFORM\t[Optional] Platform, ignored."
Expand All @@ -26,6 +27,9 @@ while getopts ":h:v:s:o:p:a:" arg; do
v)
VERSION=$OPTARG
;;
q)
QUALIFIER=$OPTARG
;;
s)
SNAPSHOT=$OPTARG
;;
Expand Down Expand Up @@ -56,21 +60,22 @@ if [ -z "$VERSION" ]; then
exit 1
fi

[[ ! -z "$QUALIFIER" ]] && VERSION=$VERSION-$QUALIFIER
[[ "$SNAPSHOT" == "true" ]] && VERSION=$VERSION-SNAPSHOT
[ -z "$OUTPUT" ] && OUTPUT=artifacts

mkdir -p $OUTPUT/plugins

./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -x ktlint
./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Dopensearch.version=$VERSION -Dbuild.version_qualifier=$QUALIFIER -Dbuild.snapshot=$SNAPSHOT -x ktlint

zipPath=$(find . -path \*build/distributions/*.zip)
distributions="$(dirname "${zipPath}")"

echo "COPY ${distributions}/*.zip"
cp ${distributions}/*.zip ./$OUTPUT/plugins

./gradlew publishShadowPublicationToMavenLocal -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -x ktlint
./gradlew publishShadowPublicationToStagingRepository -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT
./gradlew publishShadowPublicationToMavenLocal -Dopensearch.version=$VERSION -Dbuild.version_qualifier=$QUALIFIER -Dbuild.snapshot=$SNAPSHOT -x ktlint
./gradlew publishShadowPublicationToStagingRepository -Dopensearch.version=$VERSION -Dbuild.version_qualifier=$QUALIFIER -Dbuild.snapshot=$SNAPSHOT

mkdir -p $OUTPUT/maven/org/opensearch
cp -r ./build/local-staging-repo/org/opensearch/notification $OUTPUT/maven/org/opensearch/notification
Expand Down

0 comments on commit 5246e77

Please sign in to comment.