diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..0908c71 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,34 @@ +name: Publish + +on: + release: + types: [published] + +jobs: + publish: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Publish + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYID }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYPASSWORD }} + GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }} + GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }} + TAG: ${{ github.event.release.tag_name }} + run: ./gradlew composeTreeviewPublishToMavenCentral --no-daemon diff --git a/build.gradle.kts b/build.gradle.kts index cd5cad9..e99c996 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,3 +12,20 @@ allprojects { mavenCentral() } } + +tasks.register("composeTreeviewPublishToMavenCentral") { + dependsOn( +// subprojects.mapNotNull { it.tasks.findByName("publishAndReleaseToMavenCentral") } + +// gradle.includedBuilds.map { it.task(":publishAndReleaseToMavenCentral") } + + subprojects.mapNotNull { it.tasks.findByName("publishToMavenCentral") } + + gradle.includedBuilds.map { it.task(":publishToMavenCentral") } + ) +} + +tasks.register("composeTreeviewPublishToMavenLocal") { + dependsOn( + subprojects.mapNotNull { it.tasks.findByName("publishToMavenLocal") } + + gradle.includedBuilds.map { it.task(":publishToMavenLocal") } + ) +} diff --git a/buildSrc/src/main/kotlin/compose-treeview-multiplatform-lib.gradle.kts b/buildSrc/src/main/kotlin/compose-treeview-multiplatform-lib.gradle.kts index a14d564..d99b2b7 100644 --- a/buildSrc/src/main/kotlin/compose-treeview-multiplatform-lib.gradle.kts +++ b/buildSrc/src/main/kotlin/compose-treeview-multiplatform-lib.gradle.kts @@ -38,6 +38,8 @@ kotlin { } } + applyDefaultHierarchyTemplate() + sourceSets { commonMain.dependencies { } diff --git a/buildSrc/src/main/kotlin/compose-treeview-publish.gradle.kts b/buildSrc/src/main/kotlin/compose-treeview-publish.gradle.kts new file mode 100644 index 0000000..0ba5de9 --- /dev/null +++ b/buildSrc/src/main/kotlin/compose-treeview-publish.gradle.kts @@ -0,0 +1,33 @@ +import com.vanniktech.maven.publish.SonatypeHost + +plugins { + id("org.jetbrains.dokka") + id("com.vanniktech.maven.publish") +} + +mavenPublishing { + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) + + signAllPublications() + + pom { + name = "compose-treeview" + description = "Compose Multiplatform TreeView implementation" + url = "https://github.com/vooft/compose-treeview" + licenses { + license { + name = "The MIT License" + url = "https://opensource.org/licenses/MIT" + } + } + scm { + connection = "https://github.com/vooft/compose-treeview" + url = "https://github.com/vooft/compose-treeview" + } + developers { + developer { + name = "compose-treeview team" + } + } + } +} diff --git a/compose-treeview-core/build.gradle.kts b/compose-treeview-core/build.gradle.kts index 6a2a6c3..4afbfc1 100644 --- a/compose-treeview-core/build.gradle.kts +++ b/compose-treeview-core/build.gradle.kts @@ -1,5 +1,6 @@ plugins { `compose-treeview-multiplatform-lib` + `compose-treeview-publish` alias(libs.plugins.compose.multiplatform) alias(libs.plugins.compose.compiler) } diff --git a/compose-treeview-json/build.gradle.kts b/compose-treeview-json/build.gradle.kts index 450455c..882496f 100644 --- a/compose-treeview-json/build.gradle.kts +++ b/compose-treeview-json/build.gradle.kts @@ -1,5 +1,6 @@ plugins { `compose-treeview-multiplatform-lib` + `compose-treeview-publish` alias(libs.plugins.kotlin.serialization) alias(libs.plugins.compose.multiplatform) alias(libs.plugins.compose.compiler)