-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1469 from onflow/cicd-jvm-protobuf
JVM Protobuf Updates
- Loading branch information
Showing
6 changed files
with
251 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Manually Publish Release - JVM Protobuf | ||
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: Make gradle executable | ||
run: chmod +x ./protobuf/gradlew | ||
|
||
- name: Build | ||
id: build | ||
run: cd protobuf && ./gradlew --warning-mode all check build | ||
|
||
- 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: | | ||
cd protobuf | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Manually Publish Snapshot - JVM Protobuf | ||
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 ./protobuf/gradlew | ||
|
||
- name: Build | ||
id: build | ||
run: cd protobuf && ./gradlew --warning-mode all check build | ||
|
||
- 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: | | ||
cd protobuf | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Build Pull Request - JVM Protobuf | ||
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: Setup Java | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '21' | ||
java-package: jdk | ||
distribution: 'adopt' | ||
|
||
- name: Make gradle executable | ||
run: chmod +x ./protobuf/gradlew | ||
|
||
- name: Build | ||
id: build | ||
run: cd protobuf && ./gradlew --warning-mode all check build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,88 @@ | ||
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" | ||
id("com.google.protobuf") version "0.9.4" | ||
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" | ||
|
||
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.named("generateProto") { | ||
dependsOn(tasks.named("processResources")) | ||
dependsOn(tasks.named("extractIncludeTestProto")) | ||
dependsOn(tasks.named("extractTestProto")) | ||
} | ||
|
||
tasks { | ||
mavenPublishing { | ||
publishToMavenCentral(SonatypeHost.DEFAULT, true) | ||
|
||
coordinates(group.toString(), "flow", 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:[email protected]/onflow/flow.git") | ||
developerConnection.set("scm:git:[email protected]/onflow/flow.git") | ||
} | ||
developers { | ||
developer { | ||
name.set("Flow Developers") | ||
url.set("https://onflow.org") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
protobuf { | ||
protoc { | ||
artifact = "com.google.protobuf:protoc:$protobufVersion" | ||
|
@@ -30,54 +101,13 @@ 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() | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("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) | ||
url.set("https://onflow.org") | ||
description.set("The Flow Blockchain") | ||
scm { | ||
url.set("https://github.com/onflow/flow") | ||
connection.set("scm:git:[email protected]/onflow/flow.git") | ||
developerConnection.set("scm:git:[email protected]/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 +127,7 @@ java { | |
withSourcesJar() | ||
} | ||
|
||
tasks.compileJava { | ||
sourceCompatibility = "1.8" | ||
targetCompatibility = "1.8" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
group = "org.onflow" | ||
|
||
// TODO - grab version from Git | ||
version = "0.21" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |