Skip to content

Commit

Permalink
build: generalize publishing setup
Browse files Browse the repository at this point in the history
Do not have 'hedera-services' specifics in plugins so that they may
be reused without modification in other repositories.

For this, we introduce two files in the folder for each "product"
- developers.properties
- description.txt (optional)

See changes in the PR for what these files contain.

Signed-off-by: Jendrik Johannes <[email protected]>
  • Loading branch information
jjohannes committed Oct 7, 2024
1 parent 7b3b0d6 commit 9488b14
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 106 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/node-zxc-build-release-artifact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ jobs:
NEXUS_PASSWORD: ${{ secrets.sdk-ossrh-password }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: "release${{ inputs.release-profile }} -PpublishingPackageGroup=com.swirlds --scan -PpublishSigningEnabled=true --no-configuration-cache"
arguments: "release${{ inputs.release-profile }} -PpublishingPackageGroup=com.swirlds -Ps01SonatypeHost=true -PpublishSigningEnabled=true --scan --no-configuration-cache"

- name: Gradle Publish Services to ${{ inputs.version-policy == 'specified' && 'Maven Central' || 'Google Artifact Registry' }} (${{ inputs.release-profile }})
uses: gradle/gradle-build-action@29c0906b64b8fc82467890bfb7a0a7ef34bda89e # v3.1.0
Expand All @@ -881,7 +881,7 @@ jobs:
NEXUS_PASSWORD: ${{ secrets.svcs-ossrh-password }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: "release${{ inputs.release-profile }} -PpublishingPackageGroup=com.hedera --scan -PpublishSigningEnabled=true --no-configuration-cache"
arguments: "release${{ inputs.release-profile }} -PpublishingPackageGroup=com.hedera.hashgraph -PpublishSigningEnabled=true --scan --no-configuration-cache"

- name: Upload SDK Release Archives
if: ${{ inputs.dry-run-enabled != true && inputs.version-policy == 'specified' && !cancelled() && !failure() }}
Expand Down
6 changes: 6 additions & 0 deletions developers.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is here for 'hapi', because that "product" is missing the toplevel folder
# (it contains the 'hapi' module directly)
[email protected]=Hedera Base Team
[email protected]=Hedera Services Team
[email protected]=Hedera Smart Contracts Team
[email protected]=Release Engineering Team
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,21 @@
* limitations under the License.
*/

import java.util.Properties

plugins {
id("java")
id("maven-publish")
id("signing")
}

tasks.withType<PublishToMavenRepository>().configureEach {
// Publishing tasks are only enabled if we publish to the matching group.
// Otherwise, Nexus configuration and credentials do not fit.
val publishingPackageGroup = providers.gradleProperty("publishingPackageGroup").orNull
enabled = publishingPackageGroup == project.group
}

java {
withJavadocJar()
withSourcesJar()
Expand All @@ -42,32 +51,69 @@ val maven =
allVariants { fromResolutionResult() }
}

suppressAllPomMetadataWarnings()

pom {
packaging = findProperty("maven.project.packaging")?.toString() ?: "jar"
name.set(project.name)
url.set("https://www.swirlds.com/")
inceptionYear.set("2016")
val devGroups = Properties()
val developerProperties = layout.projectDirectory.file("../developers.properties")
devGroups.load(
providers
.fileContents(developerProperties)
.asText
.orElse(
provider {
throw RuntimeException("${developerProperties.asFile} does not exist")
}
)
.get()
.reader()
)

url = "https://www.hashgraph.com/"
inceptionYear = "2016"

description.set(provider(project::getDescription))
description =
providers
.fileContents(layout.projectDirectory.file("../description.txt"))
.asText
.orElse(provider { project.description })
.map { it.replace("\n", " ").trim() }
.orNull

organization {
name.set("Hedera Hashgraph, LLC")
url.set("https://www.hedera.com")
name = "Hedera Hashgraph, LLC"
url = "https://www.hedera.com"
}

val repoName = isolated.rootProject.name

issueManagement {
system = "GitHub"
url = "https://github.com/hashgraph/$repoName/issues"
}

licenses {
license {
name.set("Apache License, Version 2.0")
url.set(
"https://raw.githubusercontent.com/hashgraph/hedera-services/main/LICENSE"
)
name = "Apache License, Version 2.0"
url = "https://raw.githubusercontent.com/hashgraph/$repoName/main/LICENSE"
}
}

scm {
connection.set("scm:git:git://github.com/hashgraph/hedera-services.git")
developerConnection.set("scm:git:ssh://github.com:hashgraph/hedera-services.git")
url.set("https://github.com/hashgraph/hedera-services")
connection = "scm:git:git://github.com/hashgraph/$repoName.git"
developerConnection = "scm:git:ssh://github.com:hashgraph/$repoName.git"
url = "https://github.com/hashgraph/$repoName"
}

developers {
devGroups.forEach { mail, team ->
developer {
name = team as String
email = mail as String
organization = "Hedera Hashgraph"
organizationUrl = "https://www.hedera.com"
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ plugins {
id("io.github.gradle-nexus.publish-plugin")
}

val publishingPackageGroup = providers.gradleProperty("publishingPackageGroup").getOrElse("")
val isPlatformPublish = publishingPackageGroup == "com.swirlds"

nexusPublishing {
packageGroup = publishingPackageGroup
val s01SonatypeHost = providers.gradleProperty("s01SonatypeHost").getOrElse("false").toBoolean()
packageGroup = providers.gradleProperty("publishingPackageGroup").getOrElse("")

repositories {
sonatype {
username = System.getenv("NEXUS_USERNAME")
password = System.getenv("NEXUS_PASSWORD")
if (isPlatformPublish) {
if (s01SonatypeHost) {
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
snapshotRepositoryUrl =
uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,50 +31,6 @@ if (
apply(plugin = "com.google.cloud.artifactregistry.gradle-plugin")
}

// Publishing tasks are only enabled if we publish to the matching group.
// Otherwise, Nexus configuration and credentials do not fit.
val publishingPackageGroup = providers.gradleProperty("publishingPackageGroup").getOrElse("")

tasks.withType<PublishToMavenRepository>().configureEach {
enabled = publishingPackageGroup == "com.swirlds"
}

publishing.publications.named<MavenPublication>("maven") {
pom.description =
"Swirlds is a software platform designed to build fully-distributed " +
"applications that harness the power of the cloud without servers. " +
"Now you can develop applications with fairness in decision making, " +
"speed, trust and reliability, at a fraction of the cost of " +
"traditional server-based platforms."

pom.developers {
developer {
name = "Platform Base Team"
email = "[email protected]"
organization = "Hedera Hashgraph"
organizationUrl = "https://www.hedera.com"
}
developer {
name = "Platform Hashgraph Team"
email = "[email protected]"
organization = "Hedera Hashgraph"
organizationUrl = "https://www.hedera.com"
}
developer {
name = "Platform Data Team"
email = "[email protected]"
organization = "Hedera Hashgraph"
organizationUrl = "https://www.hedera.com"
}
developer {
name = "Release Engineering Team"
email = "[email protected]"
organization = "Hedera Hashgraph"
organizationUrl = "https://www.hedera.com"
}
}
}

publishing.repositories {
maven("artifactregistry://us-maven.pkg.dev/swirlds-registry/maven-prerelease-channel") {
name = "prereleaseChannel"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,3 @@ plugins {
id("java")
id("com.hedera.gradle.maven-publish")
}

// Publishing tasks are only enabled if we publish to the matching group.
// Otherwise, Nexus configuration and credentials do not fit.
val publishingPackageGroup = providers.gradleProperty("publishingPackageGroup").getOrElse("")

tasks.withType<PublishToMavenRepository>().configureEach {
enabled = publishingPackageGroup == "com.hedera"
}

publishing {
publications {
named<MavenPublication>("maven") {
pom.developers {
developer {
name = "Hedera Base Team"
email = "[email protected]"
organization = "Hedera Hashgraph"
organizationUrl = "https://www.hedera.com"
}
developer {
name = "Hedera Services Team"
email = "[email protected]"
organization = "Hedera Hashgraph"
organizationUrl = "https://www.hedera.com"
}
developer {
name = "Hedera Smart Contracts Team"
email = "[email protected]"
organization = "Hedera Hashgraph"
organizationUrl = "https://www.hedera.com"
}
developer {
name = "Release Engineering Team"
email = "[email protected]"
organization = "Hedera Hashgraph"
organizationUrl = "https://www.hedera.com"
}
}
}
}
}
4 changes: 4 additions & 0 deletions hedera-node/developers.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hedera-base@hashgraph.com=Hedera Base Team
hedera-services@hashgraph.com=Hedera Services Team
hedera-smart-contracts@hashgraph.com=Hedera Smart Contracts Team
release-engineering@hashgraph.com=Release Engineering Team
3 changes: 3 additions & 0 deletions platform-sdk/description.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Swirlds is a software platform designed to build fully-distributed applications that harness the power of the cloud
without servers. Now you can develop applications with fairness in decision making, speed, trust and reliability, at
a fraction of the cost of traditional server-based platforms.
4 changes: 4 additions & 0 deletions platform-sdk/developers.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
platform-base@hashgraph.com=Platform Base Team
platform-hashgraph@hashgraph.com=Platform Hashgraph Team
platform-data@hashgraph.com=Platform Data Team
release-engineering@hashgraph.com=Release Engineering Team

0 comments on commit 9488b14

Please sign in to comment.