From 98ed7a28e5b73a727045e23cc5b1259863e1a11b Mon Sep 17 00:00:00 2001 From: dblock Date: Wed, 6 Oct 2021 17:13:55 +0000 Subject: [PATCH 1/2] Publish MD5 and SHA1 signatures. Signed-off-by: dblock --- .github/workflows/push-job-sched-jar.yml | 44 --------------- scripts/build.sh | 68 ++++++++++++++++++++++++ spi/build.gradle | 32 ++++++----- 3 files changed, 83 insertions(+), 61 deletions(-) delete mode 100644 .github/workflows/push-job-sched-jar.yml create mode 100755 scripts/build.sh diff --git a/.github/workflows/push-job-sched-jar.yml b/.github/workflows/push-job-sched-jar.yml deleted file mode 100644 index 8ce26d79..00000000 --- a/.github/workflows/push-job-sched-jar.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Upload SPI Jar to Maven - -on: - push: - tags: - - v* -jobs: - upload-job-scheduler-jar: - runs-on: [ubuntu-16.04] - name: Upload SPI Jar to Maven - steps: - - name: Checkout Repo - uses: actions/checkout@v2 - - - name: Configure AWS CLI - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-east-1 - - - name: Setup Java - uses: actions/setup-java@v1 - with: - java-version: '14' - - - name: Upload Job-Scheduler Jar to Maven - env: - passphrase: ${{ secrets.PASSPHRASE }} - run: | - cd .. - export JAVA14_HOME=$JAVA_HOME - aws s3 cp s3://opendistro-docs/github-actions/pgp-public-key . - aws s3 cp s3://opendistro-docs/github-actions/pgp-private-key . - - gpg --import pgp-public-key - gpg --allow-secret-key-import --import pgp-private-key - - mkdir /home/runner/.gradle - aws s3 cp s3://opendistro-docs/github-actions/gradle.properties /home/runner/.gradle/ - - cd job-scheduler/spi - - ../gradlew publishShadowPublicationToSonatype-stagingRepository -Dcompiler.java=14 -Dbuild.snapshot=false -Djavax.net.ssl.trustStore=$JAVA_HOME/lib/security/cacerts diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 00000000..e82e6876 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,68 @@ +#!/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 "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'." + 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:a:" arg; do + case $arg in + h) + usage + exit 1 + ;; + v) + VERSION=$OPTARG + ;; + s) + SNAPSHOT=$OPTARG + ;; + o) + OUTPUT=$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 publishShadowPublicationToMavenLocal -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT +mkdir -p $OUTPUT/maven/org/opensearch +cp -r ./spi/build/distributions/* $OUTPUT/maven/org/opensearch + +./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT +[ -z "$OUTPUT" ] && OUTPUT=artifacts +mkdir -p $OUTPUT/plugins +cp ./build/distributions/*.zip $OUTPUT/plugins diff --git a/spi/build.gradle b/spi/build.gradle index 36900828..6c274628 100644 --- a/spi/build.gradle +++ b/spi/build.gradle @@ -75,6 +75,11 @@ shadowJar { relocate 'com.cronutils', 'org.opensearch.jobscheduler.repackage.com.cronutils' relocate 'org.slf4j', 'org.opensearch.jobscheduler.repackage.org.slf4j' // dependency of cron-utils classifier = null + + doLast { + ant.checksum algorithm: 'md5', file: it.archivePath + ant.checksum algorithm: 'sha1', file: it.archivePath + } } test { @@ -104,12 +109,22 @@ testClusters.javaRestTest { task sourcesJar(type: Jar) { archiveClassifier.set 'sources' from sourceSets.main.allJava + + doLast { + ant.checksum algorithm: 'md5', file: it.archivePath + ant.checksum algorithm: 'sha1', file: it.archivePath + } } task javadocJar(type: Jar) { archiveClassifier.set 'javadoc' from javadoc.destinationDir dependsOn javadoc + + doLast { + ant.checksum algorithm: 'md5', file: it.archivePath + ant.checksum algorithm: 'sha1', file: it.archivePath + } } publishing { @@ -146,24 +161,7 @@ publishing { } } - repositories { - maven { - name = "sonatype-staging" - url "https://aws.oss.sonatype.org/service/local/staging/deploy/maven2" - credentials { - username project.hasProperty('ossrhUsername') ? project.property('ossrhUsername') : '' - password project.hasProperty('ossrhPassword') ? project.property('ossrhPassword') : '' - } - } - } - // TODO - enabled debug logging for the time being, remove this eventually gradle.startParameter.setShowStacktrace(ShowStacktrace.ALWAYS) gradle.startParameter.setLogLevel(LogLevel.DEBUG) } - -signing { - required { gradle.taskGraph.hasTask("publishShadowPublicationToSonatype-stagingRepository") } - sign publishing.publications.shadow -} - From b75f63812430b6e9dd268652c0412109eba8d84b Mon Sep 17 00:00:00 2001 From: dblock Date: Wed, 6 Oct 2021 19:14:14 +0000 Subject: [PATCH 2/2] Also publish 256 and 512 checksums. Signed-off-by: dblock --- spi/build.gradle | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/spi/build.gradle b/spi/build.gradle index 6c274628..a9bf3b10 100644 --- a/spi/build.gradle +++ b/spi/build.gradle @@ -75,10 +75,14 @@ shadowJar { relocate 'com.cronutils', 'org.opensearch.jobscheduler.repackage.com.cronutils' relocate 'org.slf4j', 'org.opensearch.jobscheduler.repackage.org.slf4j' // dependency of cron-utils classifier = null +} - doLast { +tasks.withType(Jar) { task -> + task.doLast { ant.checksum algorithm: 'md5', file: it.archivePath ant.checksum algorithm: 'sha1', file: it.archivePath + ant.checksum algorithm: 'sha-256', file: it.archivePath, fileext: '.sha256' + ant.checksum algorithm: 'sha-512', file: it.archivePath, fileext: '.sha512' } } @@ -109,22 +113,12 @@ testClusters.javaRestTest { task sourcesJar(type: Jar) { archiveClassifier.set 'sources' from sourceSets.main.allJava - - doLast { - ant.checksum algorithm: 'md5', file: it.archivePath - ant.checksum algorithm: 'sha1', file: it.archivePath - } } task javadocJar(type: Jar) { archiveClassifier.set 'javadoc' from javadoc.destinationDir dependsOn javadoc - - doLast { - ant.checksum algorithm: 'md5', file: it.archivePath - ant.checksum algorithm: 'sha1', file: it.archivePath - } } publishing {