From 798cf6cd7245d1facf986e3955d67aa15123278f Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Thu, 6 Jun 2024 21:35:01 +0900 Subject: [PATCH 01/16] Setting up CICD for JVM release --- .../ci-manual-publish-jvm-release.yml | 63 +++++++++++++ .../ci-manual-publish-jvm-snapshot.yml | 60 ++++++++++++ protobuf/build.gradle.kts | 91 +++++++++++-------- .../gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 179 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/ci-manual-publish-jvm-release.yml create mode 100644 .github/workflows/ci-manual-publish-jvm-snapshot.yml diff --git a/.github/workflows/ci-manual-publish-jvm-release.yml b/.github/workflows/ci-manual-publish-jvm-release.yml new file mode 100644 index 000000000..2cfe23127 --- /dev/null +++ b/.github/workflows/ci-manual-publish-jvm-release.yml @@ -0,0 +1,63 @@ +name: Manually Publish Release +on: + workflow_dispatch: + branches: + - master +jobs: + build: + name: Manually publish release + runs-on: ubuntu-latest + env: + JAVA_OPTS: -Xmx2g -Dorg.gradle.daemon=false + #services: + # flow-emulator: + # image: gcr.io/flow-container-registry/emulator + # env: + # FLOW_VERBOSE: true + # FLOW_PORT: 3569 + # FLOW_INTERVAL: 5s + # FLOW_PERSIST: false + # ports: + # - 3569:3569 + steps: + - name: Get current date + id: date + run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')" + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Java + uses: actions/setup-java@v2 + with: + java-version: '21' + java-package: jdk + distribution: 'adopt' + + - name: Install flow emulator + run: sh -ci "$(curl -fsSL https://storage.googleapis.com/flow-cli/install.sh)" + + - name: Make gradle executable + run: chmod +x ./gradlew + + - name: Build + id: build + run: ./gradlew --warning-mode all check build -x test -x integrationTest + + - name: Publish release + env: + JAVA_OPTS: -Xmx2g -Dorg.gradle.daemon=false + ORG_GRADLE_PROJECT_mavenCentralUsername: '${{ secrets.FLOW_JVM_SDK_SONATYPE_USERNAME }}' + ORG_GRADLE_PROJECT_mavenCentralPassword: '${{ secrets.FLOW_JVM_SDK_SONATYPE_PASSWORD }}' + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.FLOW_JVM_SDK_SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.FLOW_JVM_SDK_SIGNING_PASSWORD }} + + run: | + if [[ "${{ secrets.FLOW_JVM_SDK_CICD_PUBLISH_ENABLED }}" != "true" ]]; + then + exit 0; + fi + ./gradlew \ + -Psigning.key="${{ secrets.FLOW_JVM_SDK_SIGNING_KEY }}" \ + -Psigning.password="${{ secrets.FLOW_JVM_SDK_SIGNING_PASSWORD }}" \ + publishAndReleaseToMavenCentral --no-configuration-cache diff --git a/.github/workflows/ci-manual-publish-jvm-snapshot.yml b/.github/workflows/ci-manual-publish-jvm-snapshot.yml new file mode 100644 index 000000000..5ca904a38 --- /dev/null +++ b/.github/workflows/ci-manual-publish-jvm-snapshot.yml @@ -0,0 +1,60 @@ +name: Manually Publish Snapshot +on: + workflow_dispatch: + branches: + - master +jobs: + build: + name: Manually publish snapshot + runs-on: ubuntu-latest + env: + JAVA_OPTS: -Xmx2g -Dorg.gradle.daemon=false + #services: + # flow-emulator: + # image: gcr.io/flow-container-registry/emulator + # env: + # FLOW_VERBOSE: true + # FLOW_PORT: 3569 + # FLOW_INTERVAL: 5s + # FLOW_PERSIST: false + # ports: + # - 3569:3569 + steps: + - name: Get current date + id: date + run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')" + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Java + uses: actions/setup-java@v2 + with: + java-version: '21' + java-package: jdk + distribution: 'adopt' + + - name: Make gradle executable + run: chmod +x ./gradlew + + - name: Build + id: build + run: ./gradlew --warning-mode all check build -x test -x integrationTest + + - name: Publish snapshot + env: + JAVA_OPTS: -Xmx2g -Dorg.gradle.daemon=false + ORG_GRADLE_PROJECT_mavenCentralUsername: '${{ secrets.FLOW_JVM_SDK_SONATYPE_USERNAME }}' + ORG_GRADLE_PROJECT_mavenCentralPassword: '${{ secrets.FLOW_JVM_SDK_SONATYPE_PASSWORD }}' + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.FLOW_JVM_SDK_SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.FLOW_JVM_SDK_SIGNING_PASSWORD }} + + run: | + if [[ "${{ secrets.FLOW_JVM_SDK_CICD_PUBLISH_ENABLED }}" != "true" ]]; + then + exit 0; + fi + ./gradlew \ + -Psigning.key="${{ secrets.FLOW_JVM_SDK_SIGNING_KEY }}" \ + -Psigning.password="${{ secrets.FLOW_JVM_SDK_SIGNING_PASSWORD }}" \ + publishToMavenCentral --no-configuration-cache diff --git a/protobuf/build.gradle.kts b/protobuf/build.gradle.kts index 85e102ed8..1c13deb33 100644 --- a/protobuf/build.gradle.kts +++ b/protobuf/build.gradle.kts @@ -1,17 +1,41 @@ import com.google.protobuf.gradle.* +import com.vanniktech.maven.publish.SonatypeHost +fun getProp(name: String, defaultValue: String? = null): String? { + return project.findProperty("flow.$name")?.toString()?.trim()?.ifBlank { null } + ?: project.findProperty(name)?.toString()?.trim()?.ifBlank { null } + ?: defaultValue +} + +// configuration variables +val defaultGroupId = "org.onflow" +val defaultVersion = "1.0.0" + +group = getProp("groupId", defaultGroupId)!! +version = when { + getProp("version") !in setOf("unspecified", null) -> { getProp("version")!! } + getProp("snapshotDate") != null -> { "${defaultVersion.replace("-SNAPSHOT", "")}.${getProp("snapshotDate")!!}-SNAPSHOT" } + else -> { defaultVersion } +} plugins { id("com.google.protobuf") version "0.8.15" + kotlin("jvm") version "1.9.22" `java-library` `maven-publish` signing id("io.github.gradle-nexus.publish-plugin") version "1.0.0" + id ("com.vanniktech.maven.publish") version "0.28.0" } val protobufVersion = "3.14.0" val grpcVersion = "1.35.0" +java { + sourceCompatibility = JavaVersion.VERSION_20 + targetCompatibility = JavaVersion.VERSION_20 +} + protobuf { protoc { artifact = "com.google.protobuf:protoc:$protobufVersion" @@ -44,40 +68,44 @@ nexusPublishing { } } -publishing { - publications { - create("mavenJava") { - from(components["java"]) - - pom { - licenses { - license { - name.set("The Apache License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") - } - } - name.set(project.name) +mavenPublishing { + publishToMavenCentral(SonatypeHost.DEFAULT, true) + + coordinates(group.toString(), "flow-jvm-sdk", version.toString()) + + signAllPublications() + + pom { + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + name.set(project.name) + url.set("https://onflow.org") + description.set("The Flow Blockchain") + scm { + url.set("https://github.com/onflow/flow") + connection.set("scm:git:git@github.com/onflow/flow.git") + developerConnection.set("scm:git:git@github.com/onflow/flow.git") + } + developers { + developer { + name.set("Flow Developers") url.set("https://onflow.org") - description.set("The Flow Blockchain") - scm { - url.set("https://github.com/onflow/flow") - connection.set("scm:git:git@github.com/onflow/flow.git") - developerConnection.set("scm:git:git@github.com/onflow/flow.git") - } - developers { - developer { - name.set("Flow Developers") - url.set("https://onflow.org") - } - } } } } } signing { - useGpgCmd() //use gpg2 - sign(publishing.publications["mavenJava"]) + if (getProp("signing.key") != null) { + useInMemoryPgpKeys(getProp("signing.key"), getProp("signing.password")) + } else { + useGpgCmd() + } + sign(publishing.publications) } sourceSets { @@ -97,16 +125,7 @@ java { withSourcesJar() } -tasks.compileJava { - sourceCompatibility = "1.8" - targetCompatibility = "1.8" -} - repositories { mavenCentral() } -group = "org.onflow" - -// TODO - grab version from Git -version = "0.21" diff --git a/protobuf/gradle/wrapper/gradle-wrapper.properties b/protobuf/gradle/wrapper/gradle-wrapper.properties index 2a563242c..a59520664 100644 --- a/protobuf/gradle/wrapper/gradle-wrapper.properties +++ b/protobuf/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 1e0e3093440520f43bfce217ec6d6dd997d6eb69 Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Wed, 12 Jun 2024 22:13:00 +0900 Subject: [PATCH 02/16] Setting up CICD for JVM release --- protobuf/build.gradle.kts | 88 +++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 46 deletions(-) diff --git a/protobuf/build.gradle.kts b/protobuf/build.gradle.kts index 1c13deb33..9e8b08cf8 100644 --- a/protobuf/build.gradle.kts +++ b/protobuf/build.gradle.kts @@ -19,7 +19,7 @@ version = when { } plugins { - id("com.google.protobuf") version "0.8.15" + id("com.google.protobuf") version "0.9.4" kotlin("jvm") version "1.9.22" `java-library` `maven-publish` @@ -31,11 +31,52 @@ plugins { val protobufVersion = "3.14.0" val grpcVersion = "1.35.0" +dependencies { + api("com.google.protobuf:protobuf-java:$protobufVersion") + api("io.grpc:grpc-netty-shaded:$grpcVersion") + api("io.grpc:grpc-protobuf:$grpcVersion") + api("io.grpc:grpc-stub:$grpcVersion") + api("javax.annotation:javax.annotation-api:1.3.2") +} + java { sourceCompatibility = JavaVersion.VERSION_20 targetCompatibility = JavaVersion.VERSION_20 } +tasks { + mavenPublishing { + publishToMavenCentral(SonatypeHost.DEFAULT, true) + + coordinates(group.toString(), "flow-jvm-sdk", version.toString()) + + signAllPublications() + + pom { + licenses { + license { + name.set("The Apache License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + } + } + name.set(project.name) + url.set("https://onflow.org") + description.set("The Flow Blockchain") + scm { + url.set("https://github.com/onflow/flow") + connection.set("scm:git:git@github.com/onflow/flow.git") + developerConnection.set("scm:git:git@github.com/onflow/flow.git") + } + developers { + developer { + name.set("Flow Developers") + url.set("https://onflow.org") + } + } + } + } +} + protobuf { protoc { artifact = "com.google.protobuf:protoc:$protobufVersion" @@ -54,51 +95,6 @@ protobuf { } } -dependencies { - api("com.google.protobuf:protobuf-java:$protobufVersion") - api("io.grpc:grpc-netty-shaded:$grpcVersion") - api("io.grpc:grpc-protobuf:$grpcVersion") - api("io.grpc:grpc-stub:$grpcVersion") - api("javax.annotation:javax.annotation-api:1.3.2") -} - -nexusPublishing { - repositories { - sonatype() - } -} - -mavenPublishing { - publishToMavenCentral(SonatypeHost.DEFAULT, true) - - coordinates(group.toString(), "flow-jvm-sdk", version.toString()) - - signAllPublications() - - pom { - licenses { - license { - name.set("The Apache License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") - } - } - name.set(project.name) - url.set("https://onflow.org") - description.set("The Flow Blockchain") - scm { - url.set("https://github.com/onflow/flow") - connection.set("scm:git:git@github.com/onflow/flow.git") - developerConnection.set("scm:git:git@github.com/onflow/flow.git") - } - developers { - developer { - name.set("Flow Developers") - url.set("https://onflow.org") - } - } - } -} - signing { if (getProp("signing.key") != null) { useInMemoryPgpKeys(getProp("signing.key"), getProp("signing.password")) From 24aa4dd097dd56861d1f7ee3713c5bf39b65b961 Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Wed, 12 Jun 2024 22:16:08 +0900 Subject: [PATCH 03/16] Update groupId --- protobuf/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobuf/build.gradle.kts b/protobuf/build.gradle.kts index 9e8b08cf8..6c9522e5f 100644 --- a/protobuf/build.gradle.kts +++ b/protobuf/build.gradle.kts @@ -48,7 +48,7 @@ tasks { mavenPublishing { publishToMavenCentral(SonatypeHost.DEFAULT, true) - coordinates(group.toString(), "flow-jvm-sdk", version.toString()) + coordinates(group.toString(), "flow", version.toString()) signAllPublications() From 023965af975a69de414d57dc54283f00f15d1fee Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Wed, 12 Jun 2024 22:22:36 +0900 Subject: [PATCH 04/16] Update GH actions --- .github/workflows/ci-manual-publish-jvm-release.yml | 5 ++++- .github/workflows/ci-manual-publish-jvm-snapshot.yml | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-manual-publish-jvm-release.yml b/.github/workflows/ci-manual-publish-jvm-release.yml index 2cfe23127..5b02fad4f 100644 --- a/.github/workflows/ci-manual-publish-jvm-release.yml +++ b/.github/workflows/ci-manual-publish-jvm-release.yml @@ -25,7 +25,10 @@ jobs: run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')" - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v3 + + - name: Change to protobuf directory + run: cd protobuf - name: Setup Java uses: actions/setup-java@v2 diff --git a/.github/workflows/ci-manual-publish-jvm-snapshot.yml b/.github/workflows/ci-manual-publish-jvm-snapshot.yml index 5ca904a38..21e26273e 100644 --- a/.github/workflows/ci-manual-publish-jvm-snapshot.yml +++ b/.github/workflows/ci-manual-publish-jvm-snapshot.yml @@ -25,7 +25,10 @@ jobs: run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')" - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v3 + + - name: Change to protobuf directory + run: cd protobuf - name: Setup Java uses: actions/setup-java@v2 From f678fb8f0a5c1b1a0509f233837e42fe7ec8cf52 Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Wed, 12 Jun 2024 22:37:24 +0900 Subject: [PATCH 05/16] Update GH actions --- .../ci-manual-publish-jvm-release.yml | 5 +-- .../ci-manual-publish-jvm-snapshot.yml | 2 +- .../ci-pull-request-jvm-protobuf.yml | 39 +++++++++++++++++++ 3 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/ci-pull-request-jvm-protobuf.yml diff --git a/.github/workflows/ci-manual-publish-jvm-release.yml b/.github/workflows/ci-manual-publish-jvm-release.yml index 5b02fad4f..1c9146067 100644 --- a/.github/workflows/ci-manual-publish-jvm-release.yml +++ b/.github/workflows/ci-manual-publish-jvm-release.yml @@ -37,15 +37,12 @@ jobs: java-package: jdk distribution: 'adopt' - - name: Install flow emulator - run: sh -ci "$(curl -fsSL https://storage.googleapis.com/flow-cli/install.sh)" - - name: Make gradle executable run: chmod +x ./gradlew - name: Build id: build - run: ./gradlew --warning-mode all check build -x test -x integrationTest + run: ./gradlew --warning-mode all check build - name: Publish release env: diff --git a/.github/workflows/ci-manual-publish-jvm-snapshot.yml b/.github/workflows/ci-manual-publish-jvm-snapshot.yml index 21e26273e..ef48f1788 100644 --- a/.github/workflows/ci-manual-publish-jvm-snapshot.yml +++ b/.github/workflows/ci-manual-publish-jvm-snapshot.yml @@ -42,7 +42,7 @@ jobs: - name: Build id: build - run: ./gradlew --warning-mode all check build -x test -x integrationTest + run: ./gradlew --warning-mode all check build - name: Publish snapshot env: diff --git a/.github/workflows/ci-pull-request-jvm-protobuf.yml b/.github/workflows/ci-pull-request-jvm-protobuf.yml new file mode 100644 index 000000000..892dbb50c --- /dev/null +++ b/.github/workflows/ci-pull-request-jvm-protobuf.yml @@ -0,0 +1,39 @@ +name: Build Pull Request +on: pull_request + +jobs: + build: + name: Build pull request + runs-on: ubuntu-latest + env: + JAVA_OPTS: -Xmx2g -Dorg.gradle.daemon=false + #services: + # flow-emulator: + # image: gcr.io/flow-container-registry/emulator + # env: + # FLOW_VERBOSE: true + # FLOW_PORT: 3569 + # FLOW_INTERVAL: 5s + # FLOW_PERSIST: false + # ports: + # - 3569:3569 + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Change to protobuf directory + run: cd protobuf + + - name: Setup Java + uses: actions/setup-java@v2 + with: + java-version: '21' + java-package: jdk + distribution: 'adopt' + + - name: Make gradle executable + run: chmod +x ./gradlew + + - name: Build + id: build + run: ./gradlew --warning-mode all check build From e4bfd2993978a03104737099ff52e4256ca54800 Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Wed, 12 Jun 2024 22:43:46 +0900 Subject: [PATCH 06/16] Update GH actions --- .github/workflows/ci-pull-request-jvm-protobuf.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-pull-request-jvm-protobuf.yml b/.github/workflows/ci-pull-request-jvm-protobuf.yml index 892dbb50c..d7abec21a 100644 --- a/.github/workflows/ci-pull-request-jvm-protobuf.yml +++ b/.github/workflows/ci-pull-request-jvm-protobuf.yml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@v3 - name: Change to protobuf directory - run: cd protobuf + run: cd ./protobuf - name: Setup Java uses: actions/setup-java@v2 From 7c0324df56ef04b9e7ccb8723e0fa4b3cba0af6b Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Wed, 12 Jun 2024 22:45:31 +0900 Subject: [PATCH 07/16] Update GH actions --- .github/workflows/ci-pull-request-jvm-protobuf.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci-pull-request-jvm-protobuf.yml b/.github/workflows/ci-pull-request-jvm-protobuf.yml index d7abec21a..8043a1b66 100644 --- a/.github/workflows/ci-pull-request-jvm-protobuf.yml +++ b/.github/workflows/ci-pull-request-jvm-protobuf.yml @@ -21,9 +21,6 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Change to protobuf directory - run: cd ./protobuf - - name: Setup Java uses: actions/setup-java@v2 with: @@ -32,7 +29,7 @@ jobs: distribution: 'adopt' - name: Make gradle executable - run: chmod +x ./gradlew + run: chmod +x ./protobuf/gradlew - name: Build id: build From 6950d7cd870aedbef7bf08fd9e97eb3ff3f6430c Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Wed, 12 Jun 2024 22:47:33 +0900 Subject: [PATCH 08/16] Update GH actions --- .github/workflows/ci-pull-request-jvm-protobuf.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-pull-request-jvm-protobuf.yml b/.github/workflows/ci-pull-request-jvm-protobuf.yml index 8043a1b66..d28272261 100644 --- a/.github/workflows/ci-pull-request-jvm-protobuf.yml +++ b/.github/workflows/ci-pull-request-jvm-protobuf.yml @@ -33,4 +33,4 @@ jobs: - name: Build id: build - run: ./gradlew --warning-mode all check build + run: cd protobuf && ./gradlew --warning-mode all check build From a87af602e55e7b9fbe3809d2efe7a48145b0f3c0 Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Wed, 12 Jun 2024 22:49:37 +0900 Subject: [PATCH 09/16] Update GH actions --- .github/workflows/ci-manual-publish-jvm-release.yml | 5 +++-- .github/workflows/ci-manual-publish-jvm-snapshot.yml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-manual-publish-jvm-release.yml b/.github/workflows/ci-manual-publish-jvm-release.yml index 1c9146067..da6710de5 100644 --- a/.github/workflows/ci-manual-publish-jvm-release.yml +++ b/.github/workflows/ci-manual-publish-jvm-release.yml @@ -38,11 +38,11 @@ jobs: distribution: 'adopt' - name: Make gradle executable - run: chmod +x ./gradlew + run: chmod +x ./protobuf/gradlew - name: Build id: build - run: ./gradlew --warning-mode all check build + run: cd protobuf && ./gradlew --warning-mode all check build - name: Publish release env: @@ -53,6 +53,7 @@ jobs: ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.FLOW_JVM_SDK_SIGNING_PASSWORD }} run: | + cd protobuf if [[ "${{ secrets.FLOW_JVM_SDK_CICD_PUBLISH_ENABLED }}" != "true" ]]; then exit 0; diff --git a/.github/workflows/ci-manual-publish-jvm-snapshot.yml b/.github/workflows/ci-manual-publish-jvm-snapshot.yml index ef48f1788..9f7ad5670 100644 --- a/.github/workflows/ci-manual-publish-jvm-snapshot.yml +++ b/.github/workflows/ci-manual-publish-jvm-snapshot.yml @@ -38,11 +38,11 @@ jobs: distribution: 'adopt' - name: Make gradle executable - run: chmod +x ./gradlew + run: chmod +x ./protobuf/gradlew - name: Build id: build - run: ./gradlew --warning-mode all check build + run: cd protobuf && ./gradlew --warning-mode all check build - name: Publish snapshot env: @@ -53,6 +53,7 @@ jobs: ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.FLOW_JVM_SDK_SIGNING_PASSWORD }} run: | + cd protobuf if [[ "${{ secrets.FLOW_JVM_SDK_CICD_PUBLISH_ENABLED }}" != "true" ]]; then exit 0; From 33d31ca17b6ad96749bb49091eb0da2db80a7e9b Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Wed, 12 Jun 2024 22:54:48 +0900 Subject: [PATCH 10/16] Add task dependency --- protobuf/build.gradle.kts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/protobuf/build.gradle.kts b/protobuf/build.gradle.kts index 6c9522e5f..211aa4f5b 100644 --- a/protobuf/build.gradle.kts +++ b/protobuf/build.gradle.kts @@ -44,6 +44,10 @@ java { targetCompatibility = JavaVersion.VERSION_20 } +tasks.named("generateProto") { + dependsOn(tasks.named("processResources")) +} + tasks { mavenPublishing { publishToMavenCentral(SonatypeHost.DEFAULT, true) From 80fbe17d5baf328bb068f0a87138622024e2d2cd Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Wed, 12 Jun 2024 22:58:21 +0900 Subject: [PATCH 11/16] Add task dependency --- protobuf/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/protobuf/build.gradle.kts b/protobuf/build.gradle.kts index 211aa4f5b..b5ecd7d50 100644 --- a/protobuf/build.gradle.kts +++ b/protobuf/build.gradle.kts @@ -46,6 +46,7 @@ java { tasks.named("generateProto") { dependsOn(tasks.named("processResources")) + dependsOn(tasks.named("extractIncludeTestProto")) } tasks { From 0c887a900d8fafefd724c8db6e4613b57be9774e Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Wed, 12 Jun 2024 23:02:21 +0900 Subject: [PATCH 12/16] Add task dependency --- protobuf/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/protobuf/build.gradle.kts b/protobuf/build.gradle.kts index b5ecd7d50..c42ac15ee 100644 --- a/protobuf/build.gradle.kts +++ b/protobuf/build.gradle.kts @@ -47,6 +47,7 @@ java { tasks.named("generateProto") { dependsOn(tasks.named("processResources")) dependsOn(tasks.named("extractIncludeTestProto")) + dependsOn(tasks.named("extractTestProto")) } tasks { From 17b02c16ed8f2108a84c36a1d1b3e42b61ef3c4f Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Wed, 12 Jun 2024 23:05:13 +0900 Subject: [PATCH 13/16] Add task dependency --- .github/workflows/ci-pull-request-jvm-protobuf.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-pull-request-jvm-protobuf.yml b/.github/workflows/ci-pull-request-jvm-protobuf.yml index d28272261..38ad0d1d1 100644 --- a/.github/workflows/ci-pull-request-jvm-protobuf.yml +++ b/.github/workflows/ci-pull-request-jvm-protobuf.yml @@ -1,4 +1,4 @@ -name: Build Pull Request +name: Build Pull Request - JVM Protobuf on: pull_request jobs: From 3d53865298c864716fac3d07a958718995142fc1 Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Wed, 12 Jun 2024 23:07:01 +0900 Subject: [PATCH 14/16] Update GH actions --- .github/workflows/ci-manual-publish-jvm-release.yml | 3 --- .github/workflows/ci-manual-publish-jvm-snapshot.yml | 3 --- 2 files changed, 6 deletions(-) diff --git a/.github/workflows/ci-manual-publish-jvm-release.yml b/.github/workflows/ci-manual-publish-jvm-release.yml index da6710de5..ff95872c5 100644 --- a/.github/workflows/ci-manual-publish-jvm-release.yml +++ b/.github/workflows/ci-manual-publish-jvm-release.yml @@ -27,9 +27,6 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Change to protobuf directory - run: cd protobuf - - name: Setup Java uses: actions/setup-java@v2 with: diff --git a/.github/workflows/ci-manual-publish-jvm-snapshot.yml b/.github/workflows/ci-manual-publish-jvm-snapshot.yml index 9f7ad5670..aaad8b3b0 100644 --- a/.github/workflows/ci-manual-publish-jvm-snapshot.yml +++ b/.github/workflows/ci-manual-publish-jvm-snapshot.yml @@ -27,9 +27,6 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Change to protobuf directory - run: cd protobuf - - name: Setup Java uses: actions/setup-java@v2 with: From b3846eae071af9740f2dd16980645768dc739a6f Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Wed, 12 Jun 2024 23:08:38 +0900 Subject: [PATCH 15/16] Update GH actions --- .github/workflows/ci-manual-publish-jvm-release.yml | 2 +- .github/workflows/ci-manual-publish-jvm-snapshot.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-manual-publish-jvm-release.yml b/.github/workflows/ci-manual-publish-jvm-release.yml index ff95872c5..3ad33415b 100644 --- a/.github/workflows/ci-manual-publish-jvm-release.yml +++ b/.github/workflows/ci-manual-publish-jvm-release.yml @@ -1,4 +1,4 @@ -name: Manually Publish Release +name: Manually Publish Release - JVM Protobuf on: workflow_dispatch: branches: diff --git a/.github/workflows/ci-manual-publish-jvm-snapshot.yml b/.github/workflows/ci-manual-publish-jvm-snapshot.yml index aaad8b3b0..698a44cef 100644 --- a/.github/workflows/ci-manual-publish-jvm-snapshot.yml +++ b/.github/workflows/ci-manual-publish-jvm-snapshot.yml @@ -1,4 +1,4 @@ -name: Manually Publish Snapshot +name: Manually Publish Snapshot - JVM Protobuf on: workflow_dispatch: branches: From bc4ee6387d748a975b89f6feebc74d5598f89eeb Mon Sep 17 00:00:00 2001 From: Lea Lobanov Date: Wed, 12 Jun 2024 23:35:17 +0900 Subject: [PATCH 16/16] Update release documentation --- protobuf/README.md | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/protobuf/README.md b/protobuf/README.md index 6db032358..ab3c45222 100644 --- a/protobuf/README.md +++ b/protobuf/README.md @@ -27,12 +27,19 @@ JVM support is in the alpha stage; many steps require manual intervention. `./gradlew generateProto` compiles Protobuf files into local Java classes. -### Publishing +### Publishing with GitHub Actions -`./gradlew publishToSonatype` prepares and publishes compiled classes into JAR and uploads to OSSRH staging repository. +The "com.vanniktech.maven.publish" plugin is used to automate Maven releases for JVM protobuf generation. More information on the release process can be found here [here](https://vanniktech.github.io/gradle-maven-publish-plugin/central/). -This requires signing artifacts which is done by [Signing Gradle plugin](https://docs.gradle.org/current/userguide/signing_plugin.html) - it requires -external configuration and appropriate GPG Keys. Please refer to plugin and [OSSRH](https://central.sonatype.org/pages/working-with-pgp-signatures.html) -documentation. -Uploading to staging repo requires an approved Sonatype account. Please refer to [Gradle Nexus Publish Plugin](https://github.com/gradle-nexus/publish-plugin) -documentation how to provide credentials. +There are two GitHub Actions configured to run on the master branch: + +- SNAPSHOT: On every commit to the `master` branch a build is performed and if successful it is deployed as a snapshot version. +- RELEASE: Whenever a tag is created with the pattern of `vXXX` a version with the name XXX is built and if successful deployed as a release version. + +The following GitHub repository secrets configure these actions: + +- `FLOW_JVM_SDK_CICD_PUBLISH_ENABLED`: (optional) Must be `true` for the publishing of artifacts to happen (defaults to `false`) +- `FLOW_JVM_SDK_SIGNING_KEY`: (required if publish enabled) ascii armored version of the pgp key for signing releases +- `FLOW_JVM_SDK_SIGNING_PASSWORD`: (required if publish enabled) password to the pgp key +- `FLOW_JVM_SDK_SONATYPE_USERNAME`: (required if publish enabled) sonatype username +- `FLOW_JVM_SDK_SONATYPE_PASSWORD`: (required if publish enabled) sonatype password