From 14ff129eb7acb7fb5fcd67fefc990c72d0c21ceb Mon Sep 17 00:00:00 2001 From: Robert Jamison <65142411+robertjamison@users.noreply.github.com> Date: Sat, 28 Jun 2025 13:59:16 -0400 Subject: [PATCH 01/14] Central Sonatype Migration Added Vanniktech Maven-Publishing plugin to handle migration to Maven Central. Tried to use `maven-publishing` library, but it doesn't perform necessary webhooks yet. --- build.gradle.kts | 114 +++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 59 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 6511936..704a91d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -30,77 +30,73 @@ allprojects { apply(plugin = "org.jetbrains.kotlin.plugin.serialization") apply(plugin = "org.jetbrains.kotlinx.kover") + apply(plugin = "com.vanniktech.maven.publish") apply(plugin = "org.jetbrains.dokka") apply(plugin = "maven-publish") - apply(plugin = "signing") - - extensions.configure { - repositories { - maven { - val isSnapshot = version.toString().endsWith("SNAPSHOT") - url = uri( - if (!isSnapshot) "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2" - else "https://s01.oss.sonatype.org/content/repositories/snapshots" - ) - - credentials { - username = gradleLocalProperties(rootDir).getProperty("sonatypeUsername") - password = gradleLocalProperties(rootDir).getProperty("sonatypePassword") - } - } - } + extensions.configure { val javadocJar = tasks.register("javadocJar") { dependsOn(tasks.dokkaHtml) archiveClassifier.set("javadoc") from("$buildDir/dokka") } - publications { - withType { - artifact(javadocJar) + mavenPublishing { + artifacts.dokka(javadocJar) + val isSnapshot = version.toString().endsWith("SNAPSHOT") + publishToMavenCentral( + if (isSnapshot) { + SonatypeHost("https://central.sonatype.com/repository/maven-snapshots/") + } else { + SonatypeHost.CENTRAL_PORTAL + } + ) + /** + * IMPORTANT!!! + * Review documentation Vanniktech documentation to properly pass credentials and sign for Central Sonatype + * https://vanniktech.github.io/gradle-maven-publish-plugin/central/#secrets + * If you need an example of implementation, try this: + * ``` + * - name: Publish to MavenCentral + * if: ${{ github.event_name != 'pull_request' }} + * run: ./gradlew publishToMavenCentral --no-configuration-cache + * env: + * ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + * ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + * ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} + * ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} + * ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }} + * ``` + */ + signAllPublications() + coordinates(group.toString(), project.name, version.toString()) + } - pom { - name.set("KStore") - description.set("A tiny Kotlin multiplatform library that assists in saving and restoring objects to and from disk using kotlinx.coroutines, kotlinx.serialisation and okio") - licenses { - license { - name.set("Apache-2.0") - url.set("https://opensource.org/licenses/Apache-2.0") - } - } - url.set("https://xxfast.github.io/KStore/") - issueManagement { - system.set("Github") - url.set("https://github.com/xxfast/KStore/issues") - } - scm { - connection.set("https://github.com/xxfast/KStore.git") - url.set("https://github.com/xxfast/KStore") - } - developers { - developer { - name.set("Isuru Rajapakse") - email.set("isurukusumal36@gmail.com") - } - } + pom { + name = "Kstore" + description = "A tiny Kotlin multiplatform library that assists in saving and restoring objects to and from disk using kotlinx.coroutines, kotlinx.serialisation and okio" + url = "https://xxfast.github.io/KStore/" + licenses { + license { + name = "Apache-2.0" + url = "https://opensource.org/licenses/Apache-2.0" + } + } + issueManagement { + system = "Github" + url = "https://github.com/xxfast/KStore/issues" + } + scm { + developerConnection = "scm:git:ssh://git@github.com/xxfast/KStore.git" + connection = "https://github.com/xxfast/KStore.git" + url = "https://github.com/xxfast/KStore" + } + developers { + developer { + name = "Isuru Rajapakse" + email = "isurukusumal36@gmail.com" } } } } - - val publishing = extensions.getByType() - extensions.configure { - useInMemoryPgpKeys( - gradleLocalProperties(rootDir).getProperty("gpgKeySecret"), - gradleLocalProperties(rootDir).getProperty("gpgKeyPassword"), - ) - - sign(publishing.publications) - } - - // TODO: remove after https://youtrack.jetbrains.com/issue/KT-46466 is fixed - project.tasks.withType(AbstractPublishToMaven::class.java).configureEach { - dependsOn(project.tasks.withType(Sign::class.java)) - } } From 1b1d4ccdd84ba54c60d159adc045c3827591db39 Mon Sep 17 00:00:00 2001 From: xxfast Date: Sun, 6 Jul 2025 13:47:27 +1000 Subject: [PATCH 02/14] Prepare for snapshot 1.1.0 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 704a91d..3b0a5bd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,7 +26,7 @@ allprojects { } group = "io.github.xxfast" - version = "1.0.0" + version = "1.1.0-SNAPSHOT" apply(plugin = "org.jetbrains.kotlin.plugin.serialization") apply(plugin = "org.jetbrains.kotlinx.kover") From 9bb44099f38e5c22b62b439e5963019758c67440 Mon Sep 17 00:00:00 2001 From: xxfast Date: Sun, 6 Jul 2025 13:48:21 +1000 Subject: [PATCH 03/14] Migrate to vanniktech maven publish plugin --- build.gradle.kts | 43 +++++---------------------------------- gradle/libs.versions.toml | 2 ++ 2 files changed, 7 insertions(+), 38 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3b0a5bd..aa548bd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,4 @@ -import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties +import com.vanniktech.maven.publish.MavenPublishBaseExtension plugins { id("org.jetbrains.kotlinx.kover") version "0.8.2" @@ -16,6 +16,7 @@ buildscript { classpath(libs.agp) classpath(libs.kotlin) classpath(libs.kotlin.serialization) + classpath(libs.vanniktech.maven.publish) } } @@ -32,45 +33,11 @@ allprojects { apply(plugin = "org.jetbrains.kotlinx.kover") apply(plugin = "com.vanniktech.maven.publish") apply(plugin = "org.jetbrains.dokka") - apply(plugin = "maven-publish") extensions.configure { - val javadocJar = tasks.register("javadocJar") { - dependsOn(tasks.dokkaHtml) - archiveClassifier.set("javadoc") - from("$buildDir/dokka") - } - - mavenPublishing { - artifacts.dokka(javadocJar) - val isSnapshot = version.toString().endsWith("SNAPSHOT") - publishToMavenCentral( - if (isSnapshot) { - SonatypeHost("https://central.sonatype.com/repository/maven-snapshots/") - } else { - SonatypeHost.CENTRAL_PORTAL - } - ) - /** - * IMPORTANT!!! - * Review documentation Vanniktech documentation to properly pass credentials and sign for Central Sonatype - * https://vanniktech.github.io/gradle-maven-publish-plugin/central/#secrets - * If you need an example of implementation, try this: - * ``` - * - name: Publish to MavenCentral - * if: ${{ github.event_name != 'pull_request' }} - * run: ./gradlew publishToMavenCentral --no-configuration-cache - * env: - * ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} - * ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} - * ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} - * ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} - * ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }} - * ``` - */ - signAllPublications() - coordinates(group.toString(), project.name, version.toString()) - } + publishToMavenCentral() + signAllPublications() + coordinates(group.toString(), project.name, version.toString()) pom { name = "Kstore" diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0476979..784f8e4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,6 +9,7 @@ kotlinx-coroutines = "1.10.2" kotlinx-serialization = "1.8.1" kotlinx-io = "0.7.0" turbine = "1.1.0" +vanniktech-maven-publish = "0.33.0" [libraries] agp = { module = "com.android.tools.build:gradle", version.ref = "agp" } @@ -25,3 +26,4 @@ kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serializa kotlinx-serialization-json-io = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json-io", version.ref = "kotlinx-serialization" } kotlinx-io = { module = "org.jetbrains.kotlinx:kotlinx-io-core", version.ref = "kotlinx-io" } turbine = { module = "app.cash.turbine:turbine", version.ref = "turbine" } +vanniktech-maven-publish = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "vanniktech-maven-publish" } \ No newline at end of file From 72b83c5109e5b3f34d8cc7dbd22fdc6a5a76daeb Mon Sep 17 00:00:00 2001 From: xxfast Date: Sun, 6 Jul 2025 13:48:54 +1000 Subject: [PATCH 04/14] Add TODO to migrate away from allprojects in build.gradle.kts --- build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/build.gradle.kts b/build.gradle.kts index aa548bd..f6aa007 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,6 +20,7 @@ buildscript { } } +// TODO: Migrate away from allprojects allprojects { repositories { google() From 42c0bc9d253e9fd2a6b76b2da8f67deb9e636dac Mon Sep 17 00:00:00 2001 From: xxfast Date: Sun, 6 Jul 2025 13:49:50 +1000 Subject: [PATCH 05/14] Bypass secret writes to local.properties and rely on envs --- .github/workflows/build.yml | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2532f40..2769195 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -84,10 +84,8 @@ jobs: release: name: Release ${{ matrix.module }} to Sonatype - strategy: - matrix: - module: [kstore, kstore-file, kstore-storage] - if: ${{ github.event_name != 'pull_request' }} + # TODO: Remove after testing + # if: ${{ github.event_name != 'pull_request' }} runs-on: macos-latest needs: - build @@ -104,22 +102,13 @@ jobs: - name: Setup gradle uses: gradle/gradle-build-action@v2 - - name: Write secrets to local.properties - if: ${{ github.event_name != 'pull_request' }} - run: | - echo sonatypeUsername="${SONATYPE_USERNAME}" >> "local.properties" - echo sonatypePassword="${SONATYPE_PASSWORD}" >> "local.properties" - echo gpgKeyPassword="${GPG_KEY_PASSWORD}" >> "local.properties" - echo gpgKeySecret="${GPG_KEY_SECRET}" >> "local.properties" - env: - SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} - SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} - GPG_KEY_PASSWORD: ${{ secrets.GPG_KEY_PASSWORD }} - GPG_KEY_SECRET: ${{ secrets.GPG_KEY_SECRET }} - - name: Release to sonatype - run: ./gradlew :${{ matrix.module }}:publishAllPublicationsToMavenRepository - + run: ./gradlew :publishToMavenCentral --no-configuration-cache + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_KEY_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_SECRET }} documentation: name: Publish documentation From 2497b0d4e7d5b5ab4f3f57cddb5a057721189e0e Mon Sep 17 00:00:00 2001 From: xxfast Date: Sun, 6 Jul 2025 14:20:54 +1000 Subject: [PATCH 06/14] Configure Sonatype host for Maven Central publishing for snapshots --- build.gradle.kts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index f6aa007..7a19b1d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,5 @@ import com.vanniktech.maven.publish.MavenPublishBaseExtension +import com.vanniktech.maven.publish.SonatypeHost plugins { id("org.jetbrains.kotlinx.kover") version "0.8.2" @@ -35,8 +36,13 @@ allprojects { apply(plugin = "com.vanniktech.maven.publish") apply(plugin = "org.jetbrains.dokka") + val isSnapshot: Boolean = version.toString().endsWith("SNAPSHOT") + val host: SonatypeHost = + if (isSnapshot) SonatypeHost("https://central.sonatype.com/repository/maven-snapshots/") + else SonatypeHost.CENTRAL_PORTAL + extensions.configure { - publishToMavenCentral() + publishToMavenCentral(host) signAllPublications() coordinates(group.toString(), project.name, version.toString()) From a00f070ad925c5c0fb3e31a46445b351e4fdc65a Mon Sep 17 00:00:00 2001 From: xxfast Date: Sun, 6 Jul 2025 14:39:13 +1000 Subject: [PATCH 07/14] Remove no-configuration-cache option from Maven Central publish step --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2769195..f4c9041 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -103,7 +103,7 @@ jobs: uses: gradle/gradle-build-action@v2 - name: Release to sonatype - run: ./gradlew :publishToMavenCentral --no-configuration-cache + run: ./gradlew :publishToMavenCentral env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} From e41f9e0d6ec647aec5032fad8ff74e26675cb8cb Mon Sep 17 00:00:00 2001 From: xxfast Date: Sun, 6 Jul 2025 15:00:12 +1000 Subject: [PATCH 08/14] Remove Sonatype host configuration for Maven Central publishing --- build.gradle.kts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7a19b1d..f6aa007 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,4 @@ import com.vanniktech.maven.publish.MavenPublishBaseExtension -import com.vanniktech.maven.publish.SonatypeHost plugins { id("org.jetbrains.kotlinx.kover") version "0.8.2" @@ -36,13 +35,8 @@ allprojects { apply(plugin = "com.vanniktech.maven.publish") apply(plugin = "org.jetbrains.dokka") - val isSnapshot: Boolean = version.toString().endsWith("SNAPSHOT") - val host: SonatypeHost = - if (isSnapshot) SonatypeHost("https://central.sonatype.com/repository/maven-snapshots/") - else SonatypeHost.CENTRAL_PORTAL - extensions.configure { - publishToMavenCentral(host) + publishToMavenCentral() signAllPublications() coordinates(group.toString(), project.name, version.toString()) From 2558b744238feb5da1dff12937d033e8910d1474 Mon Sep 17 00:00:00 2001 From: xxfast Date: Sun, 6 Jul 2025 16:13:09 +1000 Subject: [PATCH 09/14] Add no-configuration-cache option to Maven Central publish step --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f4c9041..2769195 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -103,7 +103,7 @@ jobs: uses: gradle/gradle-build-action@v2 - name: Release to sonatype - run: ./gradlew :publishToMavenCentral + run: ./gradlew :publishToMavenCentral --no-configuration-cache env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} From 0af618c354d5493e09e0427e5f2b90cbf8618a93 Mon Sep 17 00:00:00 2001 From: xxfast Date: Sun, 6 Jul 2025 16:22:25 +1000 Subject: [PATCH 10/14] Add GPG key ID to environment variables for signing --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2769195..7341697 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -107,6 +107,7 @@ jobs: env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_KEY_ID }} ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_KEY_PASSWORD }} ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_SECRET }} From 29ee715a69cd75e979417deabfd87354a301a46a Mon Sep 17 00:00:00 2001 From: xxfast Date: Sun, 6 Jul 2025 16:23:14 +1000 Subject: [PATCH 11/14] Prepare for release 1.0.1 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index f6aa007..881194f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,7 +28,7 @@ allprojects { } group = "io.github.xxfast" - version = "1.1.0-SNAPSHOT" + version = "1.0.1" apply(plugin = "org.jetbrains.kotlin.plugin.serialization") apply(plugin = "org.jetbrains.kotlinx.kover") From 6155bd9f1d4d2802961fcaa77ad9c2d63b433157 Mon Sep 17 00:00:00 2001 From: xxfast Date: Sun, 6 Jul 2025 16:45:18 +1000 Subject: [PATCH 12/14] Update Maven Central publish step to use publishAllPublications and add no-parallel option --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7341697..dfc8e53 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -103,7 +103,7 @@ jobs: uses: gradle/gradle-build-action@v2 - name: Release to sonatype - run: ./gradlew :publishToMavenCentral --no-configuration-cache + run: ./gradlew :publishAllPublicationsToMavenCentralRepository --no-parallel --no-configuration-cache env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} From 421cb7a222687b5cf512492dea7de0d176171693 Mon Sep 17 00:00:00 2001 From: xxfast Date: Sun, 6 Jul 2025 16:45:51 +1000 Subject: [PATCH 13/14] Prepare for snapshot 1.1.0 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 881194f..f6aa007 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,7 +28,7 @@ allprojects { } group = "io.github.xxfast" - version = "1.0.1" + version = "1.1.0-SNAPSHOT" apply(plugin = "org.jetbrains.kotlin.plugin.serialization") apply(plugin = "org.jetbrains.kotlinx.kover") From ad145b97ee639b319ba488c2a5ab03168511f673 Mon Sep 17 00:00:00 2001 From: xxfast Date: Thu, 4 Dec 2025 07:54:22 +1100 Subject: [PATCH 14/14] Update Maven Central publish step to include no-build-cache and rerun-tasks options --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dfc8e53..a5f634e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -103,7 +103,7 @@ jobs: uses: gradle/gradle-build-action@v2 - name: Release to sonatype - run: ./gradlew :publishAllPublicationsToMavenCentralRepository --no-parallel --no-configuration-cache + run: ./gradlew :publishAllPublicationsToMavenCentralRepository --no-parallel --no-configuration-cache --no-build-cache --rerun-tasks env: ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}