diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2532f40..a5f634e 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,14 @@ 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 :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 }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_KEY_ID }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_KEY_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_SECRET }} documentation: name: Publish documentation diff --git a/build.gradle.kts b/build.gradle.kts index 6511936..f6aa007 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,9 +16,11 @@ buildscript { classpath(libs.agp) classpath(libs.kotlin) classpath(libs.kotlin.serialization) + classpath(libs.vanniktech.maven.publish) } } +// TODO: Migrate away from allprojects allprojects { repositories { google() @@ -26,81 +28,43 @@ 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") + 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" - ) + extensions.configure { + publishToMavenCentral() + signAllPublications() + coordinates(group.toString(), project.name, version.toString()) - credentials { - username = gradleLocalProperties(rootDir).getProperty("sonatypeUsername") - password = gradleLocalProperties(rootDir).getProperty("sonatypePassword") + 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" } } - } - - val javadocJar = tasks.register("javadocJar") { - dependsOn(tasks.dokkaHtml) - archiveClassifier.set("javadoc") - from("$buildDir/dokka") - } - - publications { - withType { - artifact(javadocJar) - - 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") - } - } + 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)) - } } 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