From 716d932243138c32b3df88e4d9fbd375cb92847b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fa=C3=A7=20Eldenk?= Date: Sat, 10 Aug 2024 00:42:39 -0500 Subject: [PATCH] ci: publishing fixes --- .gitignore | 4 ++-- README.md | 7 +++++++ app/build.gradle.kts | 19 ++++++++++++++++++- build.gradle.kts | 28 ++++++---------------------- runtime-common/build.gradle.kts | 33 +++++++++++++++++++++++++-------- 5 files changed, 58 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index 9a12e40..ae590b6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ # Ignore Gradle build output directory build - +.kls_database.db .idea -.DS_Store \ No newline at end of file +.DS_Store diff --git a/README.md b/README.md index e1d1fda..ccb332b 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,13 @@ Focusing on core functionality, here is a list of known major issues: - [x] Generated `enum` fields with negative values can't be serialized / deserialized. - [ ] Make data classes with `ByteArray` implement equals and hashcode correctly. +## Releasing + +1. Make sure you set `SONATYPE_USERNAME`, `SONATYPE_PASSWORD`, `GPG_SIGNING_KEY` and `GPG_SIGNING_PASSPHRASE`. +2. `./gradlew publishToSonatype` +3. `./gradlew findSonatypeStagingRepository closeSonatypeStagingRepository` +4. `./gradlew findSonatypeStagingRepository releaseSonatypeStagingRepository` + ## Contribution For starters, start by checking [issues](./issues). diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e712a71..b8d4d91 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -6,9 +6,12 @@ plugins { kotlin("plugin.serialization") id("com.google.protobuf") application - `maven-publish` id("org.jetbrains.dokka") id("org.jetbrains.kotlinx.kover") + + // Publish + `maven-publish` + signing } repositories { @@ -154,3 +157,17 @@ publishing { } } } + +signing { + val signingKey = providers.environmentVariable("GPG_SIGNING_KEY") + val signingPassphrase = providers.environmentVariable("GPG_SIGNING_PASSPHRASE") + + if (signingKey.isPresent && signingPassphrase.isPresent) { + useInMemoryPgpKeys( + signingKey.get(), + signingPassphrase.get(), + ) + val extension = extensions.getByName("publishing") as PublishingExtension + sign(extension.publications) + } +} diff --git a/build.gradle.kts b/build.gradle.kts index aed84bb..8ba6a58 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,38 +1,22 @@ plugins { `maven-publish` - signing - id("io.github.gradle-nexus.publish-plugin") version "1.3.0" + id("io.github.gradle-nexus.publish-plugin") version "2.0.0" } +group = "io.github.dogacel" +version = "0.0.01" + nexusPublishing { this.repositories { sonatype { nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) - // ORG_GRADLE_PROJECT_sonatypeUsername - // ORG_GRADLE_PROJECT_sonatypePassword + username.set(System.getenv("SONATYPE_USERNAME")) + password.set(System.getenv("SONATYPE_PASSWORD")) } } } -group = "io.github.dogacel" -version = "alpha-SNAPSHOT" - -signing { - val signingKey = providers - .environmentVariable("GPG_SIGNING_KEY") - .forUseAtConfigurationTime() - val signingPassphrase = providers - .environmentVariable("GPG_SIGNING_PASSPHRASE") - .forUseAtConfigurationTime() - if (signingKey.isPresent && signingPassphrase.isPresent) { - useInMemoryPgpKeys(signingKey.get(), signingPassphrase.get()) - val extension = extensions - .getByName("publishing") as PublishingExtension - sign(extension.publications) - } -} - subprojects { apply(plugin = "org.jlleitschuh.gradle.ktlint") // Version should be inherited from parent diff --git a/runtime-common/build.gradle.kts b/runtime-common/build.gradle.kts index d90f190..1ef1ebd 100644 --- a/runtime-common/build.gradle.kts +++ b/runtime-common/build.gradle.kts @@ -4,9 +4,12 @@ plugins { id("org.jetbrains.kotlin.jvm") kotlin("plugin.serialization") `java-library` - `maven-publish` id("org.jetbrains.dokka") id("org.jetbrains.kotlinx.kover") + + // Publishing + `maven-publish` + signing } repositories { @@ -78,6 +81,16 @@ tasks.jar { // } // } +ktlint { + filter { + exclude { entry -> + val condition = + entry.file.toString().contains(".proto.kt") || entry.file.toString().contains("generated") + condition + } + } +} + // Publishing val sourcesJar by tasks.registering(Jar::class) { @@ -133,12 +146,16 @@ publishing { } } -ktlint { - filter { - exclude { entry -> - val condition = - entry.file.toString().contains(".proto.kt") || entry.file.toString().contains("generated") - condition - } +signing { + val signingKey = providers.environmentVariable("GPG_SIGNING_KEY") + val signingPassphrase = providers.environmentVariable("GPG_SIGNING_PASSPHRASE") + + if (signingKey.isPresent && signingPassphrase.isPresent) { + useInMemoryPgpKeys( + signingKey.get(), + signingPassphrase.get(), + ) + val extension = extensions.getByName("publishing") as PublishingExtension + sign(extension.publications) } }