From ab726314e2cda43b53ef02d7c9143691f495b324 Mon Sep 17 00:00:00 2001 From: Owais Kazi Date: Wed, 21 Jun 2023 13:42:10 -0700 Subject: [PATCH] Added release drafter for one click release of SDK Signed-off-by: Owais Kazi --- .github/workflows/release-drafter.yml | 45 +++++++++++++++++++++++++++ build.gradle | 27 +++++++++++----- 2 files changed, 64 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 00000000..961d397c --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,45 @@ +name: Release drafter + +on: + push: + tags: + - "*" + +jobs: + draft-a-release: + name: Draft a release + runs-on: ubuntu-latest + permissions: + contents: write + issues: write + steps: + - name: Checkout code + uses: actions/checkout@v3 + - id: get_data + run: | + echo "approvers=$(cat .github/CODEOWNERS | grep @ | tr -d '* ' | sed 's/@/,/g' | sed 's/,//1')" >> $GITHUB_OUTPUT + echo "version=$(./gradlew getVersion -Dbuild.snapshot=false -Dbuild -q | grep version= | cut -d'=' -f2)" >> $GITHUB_OUTPUT + - uses: trstringer/manual-approval@v1 + with: + secret: ${{ github.TOKEN }} + approvers: ${{ steps.get_data.outputs.approvers }} + minimum-approvals: 2 + issue-title: 'Release opensearch-sdk-java : ${{ steps.get_data.outputs.version }}' + issue-body: "Please approve or deny the release of opensearch-sdk-java. **VERSION**: ${{ steps.get_data.outputs.version }} **TAG**: ${{ github.ref_name }} **COMMIT**: ${{ github.sha }}" + exclude-workflow-initiator-as-approver: true + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + cache: 'gradle' + - name: Build with Gradle + run: | + ./gradlew --no-daemon -Dbuild.snapshot=false publishNebulaPublicationToLocalRepoRepository && tar -C build -cvf artifacts.tar.gz localRepo + - name: Draft a release + uses: softprops/action-gh-release@v1 + with: + draft: true + generate_release_notes: true + files: | + artifacts.tar.gz diff --git a/build.gradle b/build.gradle index 3f1870d0..7f90d17d 100644 --- a/build.gradle +++ b/build.gradle @@ -76,7 +76,7 @@ allprojects { project.ext.licenseName = 'The Apache Software License, Version 2.0' project.ext.licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' group = 'org.opensearch' - version = opensearch_version.tokenize('-')[0] + '.0' + version = '2.0.0' if (buildVersionQualifier) { version += "-${buildVersionQualifier}" } @@ -87,7 +87,6 @@ allprojects { group 'org.opensearch.sdk' -version '2.0.0-SNAPSHOT' publishing { publications { @@ -97,14 +96,20 @@ publishing { } repositories { - maven { - name = "Snapshots" // optional target repository name - url = "https://aws.oss.sonatype.org/content/repositories/snapshots" - credentials { - username "$System.env.SONATYPE_USERNAME" - password "$System.env.SONATYPE_PASSWORD" + if (version.toString().endsWith("SNAPSHOT")) { + maven { + name = "Snapshots" // optional target repository name + url = "https://aws.oss.sonatype.org/content/repositories/snapshots" + credentials { + username "$System.env.SONATYPE_USERNAME" + password "$System.env.SONATYPE_PASSWORD" + } } } + maven { + name = "localRepo" + url = "$buildDir/localRepo" + } } } @@ -201,6 +206,12 @@ task helloWorld(type: JavaExec) { classpath = sourceSets.main.runtimeClasspath } +task getVersion() { + doLast { + println("version=${version}") + } +} + test { useJUnitPlatform() jvmArgs '--enable-preview'