From afc12520016425e1d7c1f356f14ded6f6a81a441 Mon Sep 17 00:00:00 2001 From: pgodithi Date: Fri, 1 Jul 2022 12:39:05 -0400 Subject: [PATCH 1/8] test version increment automation Signed-off-by: pgodithi --- build.gradle | 28 ++++++++++++++++--- gradle.properties | 7 +++++ scripts/build.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 gradle.properties create mode 100644 scripts/build.sh diff --git a/build.gradle b/build.gradle index e69980466..623658d74 100644 --- a/build.gradle +++ b/build.gradle @@ -16,8 +16,8 @@ import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask buildscript { ext { opensearch_group = "org.opensearch" - isSnapshot = "true" == System.getProperty("build.snapshot", "true") - opensearch_version = System.getProperty("opensearch.version", "1.3.3-SNAPSHOT") + opensearch_version = project.property('opensearch.version') + isSnapshot = project.property('build.snapshot') if (isSnapshot) { plugin_version = opensearch_version.substring(0, opensearch_version.indexOf("-")) } else { @@ -137,6 +137,28 @@ configurations { } } +task versionIncrement { + final String workingDir = project.buildDir.toString() + "/../" + if(project.hasProperty('newVersion')) { + println 'Set Project to new Version '+newVersion.tokenize('-')[0] + ant.replaceregexp(match: opensearch_version.tokenize('-')[0], replace: newVersion.tokenize('-')[0], flags:'g', byline:true) { + fileset(dir: workingDir) { + include(name: ".github/workflows/CI.yml") + include(name: "build.gradle") + } + } + } +} + +task setVersion(dependsOn: versionIncrement) { + if(project.hasProperty('newVersion')) { + ant.propertyfile( + file: "gradle.properties") { + entry( key: "opensearch.version", value: "${newVersion}") + } + } +} + tasks.named('forbiddenApisMain').configure { // Only enable limited check because AD code has too many violations. replaceSignatureFiles 'jdk-signatures' @@ -764,4 +786,4 @@ validateNebulaPom.enabled = false tasks.withType(licenseHeaders.class) { additionalLicense 'AL ', 'Apache', 'Licensed under the Apache License, Version 2.0 (the "License")' -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 000000000..6dba56a06 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,7 @@ +#Fri, 01 Jul 2022 12:35:31 -0400 + +# Copyright OpenSearch Contributors +# SPDX-License-Identifier: Apache-2.0 + +opensearch.version=1.3.3-SNAPSHOT +build.snapshot=true diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100644 index 000000000..aa76361f7 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +# +# Copyright OpenSearch Contributors +# +# SPDX-License-Identifier: Apache-2.0 +# + +set -ex + +function usage() { + echo "Usage: $0 [args]" + echo "" + echo "Arguments:" + echo -e "-v VERSION\t[Required] OpenSearch version." + echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'." + echo -e "-p PLATFORM\t[Optional] Platform, ignored." + 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:s:o:p:a:" arg; do + case $arg in + h) + usage + exit 1 + ;; + v) + VERSION=$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 version" + usage + exit 1 +fi + +[[ "$SNAPSHOT" == "true" ]] && VERSION=$VERSION-SNAPSHOT +[ -z "$OUTPUT" ] && OUTPUT=artifacts + +./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Popensearch.version=$VERSION -Pbuild.snapshot=$SNAPSHOT +[ -z "$OUTPUT" ] && OUTPUT=artifacts +mkdir -p $OUTPUT/plugins +cp ./build/distributions/*.zip $OUTPUT/plugins + From d4d1517e7734ac42e7a20040ca52ff453a76d3ac Mon Sep 17 00:00:00 2001 From: pgodithi Date: Fri, 1 Jul 2022 12:58:16 -0400 Subject: [PATCH 2/8] test version increment automation Signed-off-by: pgodithi --- build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 623658d74..1b4787294 100644 --- a/build.gradle +++ b/build.gradle @@ -136,7 +136,6 @@ configurations { exclude group: 'org.hamcrest', module: 'hamcrest-core' } } - task versionIncrement { final String workingDir = project.buildDir.toString() + "/../" if(project.hasProperty('newVersion')) { @@ -786,4 +785,4 @@ validateNebulaPom.enabled = false tasks.withType(licenseHeaders.class) { additionalLicense 'AL ', 'Apache', 'Licensed under the Apache License, Version 2.0 (the "License")' -} \ No newline at end of file +} From 264dd06a04a9d475657e05ca7da3073c29eefa4a Mon Sep 17 00:00:00 2001 From: pgodithi Date: Fri, 1 Jul 2022 12:58:26 -0400 Subject: [PATCH 3/8] test version increment automation Signed-off-by: pgodithi --- build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle b/build.gradle index 1b4787294..1c728e77f 100644 --- a/build.gradle +++ b/build.gradle @@ -136,6 +136,7 @@ configurations { exclude group: 'org.hamcrest', module: 'hamcrest-core' } } + task versionIncrement { final String workingDir = project.buildDir.toString() + "/../" if(project.hasProperty('newVersion')) { From ebcda5116770700d0ad82069c00162008d85d92a Mon Sep 17 00:00:00 2001 From: pgodithi Date: Fri, 8 Jul 2022 13:15:04 -0400 Subject: [PATCH 4/8] Version increment automation Signed-off-by: pgodithi --- build.gradle | 41 ++++++++++++---------------- gradle.properties | 7 ----- scripts/build.sh | 69 ----------------------------------------------- 3 files changed, 17 insertions(+), 100 deletions(-) delete mode 100644 gradle.properties delete mode 100644 scripts/build.sh diff --git a/build.gradle b/build.gradle index 1c728e77f..647b1fb12 100644 --- a/build.gradle +++ b/build.gradle @@ -16,8 +16,8 @@ import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask buildscript { ext { opensearch_group = "org.opensearch" - opensearch_version = project.property('opensearch.version') - isSnapshot = project.property('build.snapshot') + isSnapshot = "true" == System.getProperty("build.snapshot", "true") + opensearch_version = System.getProperty("opensearch.version", "1.3.3-SNAPSHOT") if (isSnapshot) { plugin_version = opensearch_version.substring(0, opensearch_version.indexOf("-")) } else { @@ -137,28 +137,6 @@ configurations { } } -task versionIncrement { - final String workingDir = project.buildDir.toString() + "/../" - if(project.hasProperty('newVersion')) { - println 'Set Project to new Version '+newVersion.tokenize('-')[0] - ant.replaceregexp(match: opensearch_version.tokenize('-')[0], replace: newVersion.tokenize('-')[0], flags:'g', byline:true) { - fileset(dir: workingDir) { - include(name: ".github/workflows/CI.yml") - include(name: "build.gradle") - } - } - } -} - -task setVersion(dependsOn: versionIncrement) { - if(project.hasProperty('newVersion')) { - ant.propertyfile( - file: "gradle.properties") { - entry( key: "opensearch.version", value: "${newVersion}") - } - } -} - tasks.named('forbiddenApisMain').configure { // Only enable limited check because AD code has too many violations. replaceSignatureFiles 'jdk-signatures' @@ -787,3 +765,18 @@ validateNebulaPom.enabled = false tasks.withType(licenseHeaders.class) { additionalLicense 'AL ', 'Apache', 'Licensed under the Apache License, Version 2.0 (the "License")' } + +task versionIncrement { + onlyIf { System.getProperty('newVersion') } + doLast { + ext.newVersion = System.getProperty('newVersion') + println "Setting version to ${newVersion}." + final String workingDir = project.buildDir.toString() + "/../" + ant.replaceregexp(match: opensearch_version.tokenize('-')[0], replace: newVersion.tokenize('-')[0], flags:'g', byline:true) { + fileset(dir: workingDir) { + include(name: ".github/workflows/CI.yml") + include(name: "build.gradle") + } + } + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 6dba56a06..000000000 --- a/gradle.properties +++ /dev/null @@ -1,7 +0,0 @@ -#Fri, 01 Jul 2022 12:35:31 -0400 - -# Copyright OpenSearch Contributors -# SPDX-License-Identifier: Apache-2.0 - -opensearch.version=1.3.3-SNAPSHOT -build.snapshot=true diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100644 index aa76361f7..000000000 --- a/scripts/build.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/bash - -# -# Copyright OpenSearch Contributors -# -# SPDX-License-Identifier: Apache-2.0 -# - -set -ex - -function usage() { - echo "Usage: $0 [args]" - echo "" - echo "Arguments:" - echo -e "-v VERSION\t[Required] OpenSearch version." - echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'." - echo -e "-p PLATFORM\t[Optional] Platform, ignored." - 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:s:o:p:a:" arg; do - case $arg in - h) - usage - exit 1 - ;; - v) - VERSION=$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 version" - usage - exit 1 -fi - -[[ "$SNAPSHOT" == "true" ]] && VERSION=$VERSION-SNAPSHOT -[ -z "$OUTPUT" ] && OUTPUT=artifacts - -./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Popensearch.version=$VERSION -Pbuild.snapshot=$SNAPSHOT -[ -z "$OUTPUT" ] && OUTPUT=artifacts -mkdir -p $OUTPUT/plugins -cp ./build/distributions/*.zip $OUTPUT/plugins - From f890e3cfb5d05f41549177a8aaa2620a458d21a5 Mon Sep 17 00:00:00 2001 From: pgodithi Date: Fri, 8 Jul 2022 14:09:54 -0400 Subject: [PATCH 5/8] Version increment automation Signed-off-by: pgodithi --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 647b1fb12..a11b6f924 100644 --- a/build.gradle +++ b/build.gradle @@ -771,9 +771,9 @@ task versionIncrement { doLast { ext.newVersion = System.getProperty('newVersion') println "Setting version to ${newVersion}." - final String workingDir = project.buildDir.toString() + "/../" + // String tokenization to support -SNAPSHOT ant.replaceregexp(match: opensearch_version.tokenize('-')[0], replace: newVersion.tokenize('-')[0], flags:'g', byline:true) { - fileset(dir: workingDir) { + fileset(dir: projectDir) { include(name: ".github/workflows/CI.yml") include(name: "build.gradle") } From eeb52a3065dab9d647fec020fd713f84e153e1ac Mon Sep 17 00:00:00 2001 From: pgodithi Date: Fri, 8 Jul 2022 14:19:26 -0400 Subject: [PATCH 6/8] Version increment automation Signed-off-by: pgodithi --- build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle b/build.gradle index a11b6f924..7ea376c03 100644 --- a/build.gradle +++ b/build.gradle @@ -766,6 +766,7 @@ tasks.withType(licenseHeaders.class) { additionalLicense 'AL ', 'Apache', 'Licensed under the Apache License, Version 2.0 (the "License")' } +// versionIncrement: Task to auto increment to the next development iteration task versionIncrement { onlyIf { System.getProperty('newVersion') } doLast { @@ -774,6 +775,7 @@ task versionIncrement { // String tokenization to support -SNAPSHOT ant.replaceregexp(match: opensearch_version.tokenize('-')[0], replace: newVersion.tokenize('-')[0], flags:'g', byline:true) { fileset(dir: projectDir) { + // Include the required files that needs to be updated with new Version include(name: ".github/workflows/CI.yml") include(name: "build.gradle") } From 2fd03b4bbd4ac28aa0f98574ef071c00c333a24c Mon Sep 17 00:00:00 2001 From: prudhvigodithi Date: Tue, 16 Aug 2022 15:20:17 -0400 Subject: [PATCH 7/8] release 1.3.5 Signed-off-by: prudhvigodithi --- .github/workflows/CI.yml | 22 +++++++++++----------- build.gradle | 10 +++++----- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 60d06b18e..6d5619427 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -29,28 +29,28 @@ jobs: - name: Assemble anomaly-detection run: | - ./gradlew assemble -Dopensearch.version=1.3.4-SNAPSHOT - echo "Creating ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.4.0-SNAPSHOT ..." - mkdir -p ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.4.0-SNAPSHOT - echo "Copying ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.4.0-SNAPSHOT ..." + ./gradlew assemble -Dopensearch.version=1.3.5-SNAPSHOT + echo "Creating ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.5.0-SNAPSHOT ..." + mkdir -p ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.5.0-SNAPSHOT + echo "Copying ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.5.0-SNAPSHOT ..." ls ./build/distributions/ - cp ./build/distributions/*.zip ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.4.0-SNAPSHOT - echo "Copied ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.4.0-SNAPSHOT ..." - ls ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.4.0-SNAPSHOT + cp ./build/distributions/*.zip ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.5.0-SNAPSHOT + echo "Copied ./build/distributions/*.zip to ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.5.0-SNAPSHOT ..." + ls ./src/test/resources/org/opensearch/ad/bwc/anomaly-detection/1.3.5.0-SNAPSHOT - name: Build and Run Tests run: | - ./gradlew build -Dopensearch.version=1.3.4-SNAPSHOT + ./gradlew build -Dopensearch.version=1.3.5-SNAPSHOT - name: Publish to Maven Local run: | - ./gradlew publishToMavenLocal -Dopensearch.version=1.3.4-SNAPSHOT + ./gradlew publishToMavenLocal -Dopensearch.version=1.3.5-SNAPSHOT - name: Multi Nodes Integration Testing run: | ./gradlew integTest -PnumNodes=3 - name: Pull and Run Docker run: | plugin=`ls build/distributions/*.zip` - version=1.3.4 - plugin_version=1.3.4.0-SNAPSHOT + version=1.3.5 + plugin_version=1.3.5.0-SNAPSHOT echo Using OpenSearch $version with AD $plugin_version cd .. if docker pull opensearchstaging/opensearch:$version diff --git a/build.gradle b/build.gradle index 66c78ffb2..33265ae0b 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { ext { opensearch_group = "org.opensearch" isSnapshot = "true" == System.getProperty("build.snapshot", "true") - opensearch_version = System.getProperty("opensearch.version", "1.3.4-SNAPSHOT") + opensearch_version = System.getProperty("opensearch.version", "1.3.5-SNAPSHOT") if (isSnapshot) { plugin_version = opensearch_version.substring(0, opensearch_version.indexOf("-")) } else { @@ -759,8 +759,8 @@ tasks.withType(licenseHeaders.class) { additionalLicense 'AL ', 'Apache', 'Licensed under the Apache License, Version 2.0 (the "License")' } -// versionIncrement: Task to auto increment to the next development iteration -task versionIncrement { +// updateVersion: Task to auto increment to the next development iteration +task updateVersion { onlyIf { System.getProperty('newVersion') } doLast { ext.newVersion = System.getProperty('newVersion') @@ -770,8 +770,8 @@ task versionIncrement { fileset(dir: projectDir) { // Include the required files that needs to be updated with new Version include(name: ".github/workflows/CI.yml") - include(name: "build.gradle") } } + ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true) } -} \ No newline at end of file +} From ac25d8ea7933917ea862ee08d3869e162517d2e8 Mon Sep 17 00:00:00 2001 From: prudhvigodithi Date: Wed, 17 Aug 2022 11:33:55 -0400 Subject: [PATCH 8/8] release 1.3.5 Signed-off-by: prudhvigodithi --- scripts/build.sh | 79 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 scripts/build.sh diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 000000000..5cf854065 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +# 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, ignored." + 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 version" + usage + exit 1 +fi + +[[ ! -z "$QUALIFIER" ]] && VERSION=$VERSION-$QUALIFIER +[[ "$SNAPSHOT" == "true" ]] && VERSION=$VERSION-SNAPSHOT +[ -z "$OUTPUT" ] && OUTPUT=artifacts + +mkdir -p $OUTPUT + +./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER + +zipPath=$(find . -path \*build/distributions/*.zip) +distributions="$(dirname "${zipPath}")" + +echo "COPY ${distributions}/*.zip" +mkdir -p $OUTPUT/plugins +cp ${distributions}/*.zip ./$OUTPUT/plugins