diff --git a/.github/workflows/multi-node-test-workflow.yml b/.github/workflows/multi-node-test-workflow.yml index 5120d8aed..683b992f1 100644 --- a/.github/workflows/multi-node-test-workflow.yml +++ b/.github/workflows/multi-node-test-workflow.yml @@ -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 diff --git a/.github/workflows/security-test-workflow.yml b/.github/workflows/security-test-workflow.yml index 3c2a47377..f55f14bdd 100644 --- a/.github/workflows/security-test-workflow.yml +++ b/.github/workflows/security-test-workflow.yml @@ -33,7 +33,7 @@ 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` @@ -41,13 +41,21 @@ jobs: 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 diff --git a/.github/workflows/test-workflow.yml b/.github/workflows/test-workflow.yml index 657586c12..012c1534a 100644 --- a/.github/workflows/test-workflow.yml +++ b/.github/workflows/test-workflow.yml @@ -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 diff --git a/build.gradle b/build.gradle index eef8871ec..87ebd4c6c 100644 --- a/build.gradle +++ b/build.gradle @@ -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' } @@ -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" diff --git a/scripts/build.sh b/scripts/build.sh index 8a0c6f996..ff5ed4f1f 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -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." @@ -26,6 +27,9 @@ while getopts ":h:v:s:o:p:a:" arg; do v) VERSION=$OPTARG ;; + q) + QUALIFIER=$OPTARG + ;; s) SNAPSHOT=$OPTARG ;; @@ -56,12 +60,13 @@ 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}")" @@ -69,8 +74,8 @@ 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