Skip to content

Commit

Permalink
fix: Gradle publish script
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmed Moussa <[email protected]>
  • Loading branch information
hamada147 committed Dec 14, 2023
1 parent c2bf114 commit 19d506c
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 130 deletions.
196 changes: 91 additions & 105 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ plugins {
id("org.jlleitschuh.gradle.ktlint") version "11.6.1"
id("maven-publish")
id("org.jetbrains.kotlinx.kover") version "0.7.4"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0-rc-1"
id("signing")
}

Expand Down Expand Up @@ -44,102 +43,99 @@ allprojects {
}

apply(plugin = "org.gradle.maven-publish")
apply(plugin = "org.gradle.signing")

// Disable Publish Gradle task for the following modules
val disabledProjects = listOf("iOSLibs", "secp256k1-kmp", "native")
if (disabledProjects.contains(project.name)) {
afterEvaluate {
tasks.named("publishAllPublicationsToSonatypeRepository") {
enabled = false
}
}
}
// Allowed projects to publish to maven
val allowedProjectsToPublish = listOf("apollo")

publishing {
publications {
if (allowedProjectsToPublish.contains(project.name)) {
create<MavenPublication>(project.name) {
groupId = publishedMavenId
artifactId = project.name
version = project.version.toString()
pom {
name.set("Atala PRISM Apollo")
description.set("Collection of the cryptographic methods used all around Atala PRISM")
url.set("https://docs.atalaprism.io/")
organization {
name.set("IOG")
url.set("https://iog.io/")
if (allowedProjectsToPublish.contains(project.name)) {
publications.withType<MavenPublication> {
groupId = publishedMavenId
artifactId = project.name
version = project.version.toString()
pom {
name.set("Atala PRISM Apollo")
description.set("Collection of the cryptographic methods used all around Atala PRISM")
url.set("https://docs.atalaprism.io/")
organization {
name.set("IOG")
url.set("https://iog.io/")
}
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("hamada147")
name.set("Ahmed Moussa")
email.set("[email protected]")
organization.set("IOG")
roles.add("developer")
}
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
developer {
id.set("amagyar-iohk")
name.set("Allain Magyar")
email.set("[email protected]")
organization.set("IOG")
roles.add("qc")
}
developers {
developer {
id.set("hamada147")
name.set("Ahmed Moussa")
email.set("[email protected]")
organization.set("IOG")
roles.add("developer")
}
developer {
id.set("amagyar-iohk")
name.set("Allain Magyar")
email.set("[email protected]")
organization.set("IOG")
roles.add("qc")
}
developer {
id.set("antonbaliasnikov")
name.set("Anton Baliasnikov")
email.set("[email protected]")
organization.set("IOG")
roles.add("qc")
}
developer {
id.set("elribonazo")
name.set("Javier Ribó")
email.set("[email protected]")
organization.set("IOG")
roles.add("developer")
}
developer {
id.set("goncalo-frade-iohk")
name.set("Gonçalo Frade")
email.set("[email protected]")
organization.set("IOG")
roles.add("developer")
}
developer {
id.set("curtis-h")
name.set("Curtis Harding")
email.set("[email protected]")
organization.set("IOG")
roles.add("developer")
}
developer {
id.set("cristianIOHK")
name.set("Cristian Gonzalez")
email.set("[email protected]")
organization.set("IOG")
roles.add("developer")
}
developer {
id.set("antonbaliasnikov")
name.set("Anton Baliasnikov")
email.set("[email protected]")
organization.set("IOG")
roles.add("qc")
}
scm {
connection.set("scm:git:git://input-output-hk/atala-prism-apollo.git")
developerConnection.set("scm:git:ssh://input-output-hk/atala-prism-apollo.git")
url.set("https://github.com/input-output-hk/atala-prism-apollo")
developer {
id.set("elribonazo")
name.set("Javier Ribó")
email.set("[email protected]")
organization.set("IOG")
roles.add("developer")
}
developer {
id.set("goncalo-frade-iohk")
name.set("Gonçalo Frade")
email.set("[email protected]")
organization.set("IOG")
roles.add("developer")
}
developer {
id.set("curtis-h")
name.set("Curtis Harding")
email.set("[email protected]")
organization.set("IOG")
roles.add("developer")
}
developer {
id.set("cristianIOHK")
name.set("Cristian Gonzalez")
email.set("[email protected]")
organization.set("IOG")
roles.add("developer")
}
}
scm {
connection.set("scm:git:git://input-output-hk/atala-prism-apollo.git")
developerConnection.set("scm:git:ssh://input-output-hk/atala-prism-apollo.git")
url.set("https://github.com/input-output-hk/atala-prism-apollo")
}
}
}
}
// repositories {
// // GitHub Maven Repo
repositories {
// Maven Central
maven {
name = "Sonatype"
url = uri("https://oss.sonatype.org/service/local/")
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
// GitHub Maven Repo
// maven {
// this.name = "GitHubPackages"
// this.url = uri("https://maven.pkg.github.com/input-output-hk/atala-prism-apollo")
Expand All @@ -148,7 +144,15 @@ allprojects {
// this.password = System.getenv("ATALA_GITHUB_TOKEN")
// }
// }
// }
}
}
}

signing {
val base64EncodedAsciiArmoredSigningKey: String = System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") ?: ""
val signingKeyPassword: String = System.getenv("SIGNING_KEY_PASSWORD") ?: ""
useInMemoryPgpKeys(String(Base64.getDecoder().decode(base64EncodedAsciiArmoredSigningKey.toByteArray())), signingKeyPassword)
sign(publishing.publications)
}
}

Expand Down Expand Up @@ -188,21 +192,3 @@ subprojects {
rootProject.plugins.withType(NodeJsRootPlugin::class.java) {
rootProject.extensions.getByType(NodeJsRootExtension::class.java).nodeVersion = "16.17.0"
}

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots/"))
username.set(System.getenv("SONATYPE_USERNAME"))
password.set(System.getenv("SONATYPE_PASSWORD"))
}
}
}

signing {
val base64EncodedAsciiArmoredSigningKey: String = System.getenv("BASE64_ARMORED_GPG_SIGNING_KEY_MAVEN") ?: ""
val signingKeyPassword: String = System.getenv("SIGNING_KEY_PASSWORD") ?: ""
useInMemoryPgpKeys(String(Base64.getDecoder().decode(base64EncodedAsciiArmoredSigningKey.toByteArray())), signingKeyPassword)
sign(publishing.publications)
}
8 changes: 7 additions & 1 deletion iOSLibs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,16 @@ libraries.forEach { library ->
}
}

tasks.create<Delete>("clean") {
val deleteBuildFolder by tasks.register<Delete>("deleteBuildFolder") {
group = "build"
delete("$projectDir/build")
libraries.forEach {
delete("$projectDir/$it/build")
}
}

afterEvaluate {
tasks.named("clean") {
dependsOn(deleteBuildFolder)
}
}
21 changes: 0 additions & 21 deletions secp256k1-kmp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -107,24 +107,3 @@ kotlin {
// compilations["main"].kotlinOptions.freeCompilerArgs += listOf("-include-binary", "$rootDir/secp256k1-kmp/native/build/ios/arm64-appletvos/libsecp256k1.a")
// }
}

afterEvaluate {
// Disable publish of targets
if (currentOs.isMacOsX) {
tasks.named("publishIosX64PublicationToSonatypeRepository") {
this.enabled = false
}
tasks.named("publishIosArm64PublicationToSonatypeRepository") {
this.enabled = false
}
tasks.named("publishIosSimulatorArm64PublicationToSonatypeRepository") {
this.enabled = false
}
tasks.named("publishMacosArm64PublicationToSonatypeRepository") {
this.enabled = false
}
tasks.named("publishMacosX64PublicationToSonatypeRepository") {
this.enabled = false
}
}
}
10 changes: 7 additions & 3 deletions secp256k1-kmp/native/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,13 @@ val buildSecp256k1TvOSArm64 by tasks.creating(Exec::class) {
}
}

val clean by tasks.creating {
val deleteBuildFolder by tasks.register<Delete>("deleteBuildFolder") {
group = "build"
doLast {
delete(projectDir.resolve("build"))
delete(projectDir.resolve("build"))
}

afterEvaluate {
tasks.named("clean") {
dependsOn(deleteBuildFolder)
}
}

0 comments on commit 19d506c

Please sign in to comment.