Skip to content

Commit

Permalink
Merge pull request #128 from overpas/#127/update-publishing
Browse files Browse the repository at this point in the history
Update publishing configuration to support the new maven publication process
  • Loading branch information
overpas authored Oct 27, 2024
2 parents 70b31ce + 361952d commit ad6383f
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 136 deletions.
55 changes: 34 additions & 21 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,44 @@ on:

jobs:
publish:
name: Release build and publish
runs-on: ubuntu-latest
name: Publish
runs-on: macos-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 17
distribution: 'zulu'
java-version: '17'

# Builds the release artifacts of the library
- name: Release build
run: ./gradlew build
- name: Install GPG
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
run: |
brew install gpg
echo "$SIGNING_KEY" | gpg --dearmor > ${HOME}/secring.gpg
# Generates other artifacts
- name: Source jar
run: ./gradlew androidReleaseSourcesJar javadocJar
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

# Runs upload, and then closes & releases the repository
- name: Publish to MavenCentral
run: ./gradlew publishAllPublicationsToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository
- name: Add Gradle Properties
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_CENTRAL_USER_NAME: ${{ secrets.MAVEN_CENTRAL_USER_NAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
run: |
echo "mavenCentralUsername=${MAVEN_CENTRAL_USER_NAME}" >> gradle.properties
echo "mavenCentralPassword=${MAVEN_CENTRAL_PASSWORD}" >> gradle.properties
echo "signing.keyId=${SIGNING_KEY_ID}" >> gradle.properties
echo "signing.password=${SIGNING_KEY_PASSWORD}" >> gradle.properties
echo "signing.secretKeyRingFile=${HOME}/secring.gpg" >> gradle.properties
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- name: Publish To Maven Central
run: |
./gradlew publishAndReleaseToMavenCentral --no-configuration-cache
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Jetpack compose [treemap](https://en.wikipedia.org/wiki/Treemapping) chart imple
### Adding to the project
Add this to your `dependencies` gradle block:
```gradle
implementation "io.github.overpas:treemap-chart:0.1.2"
implementation "io.github.overpas:treemap-chart-compose:0.1.2"
implementation "io.github.overpas:treemap-chart:0.1.3"
implementation "io.github.overpas:treemap-chart-compose:0.1.3"
```
### Sample code
```kotlin
Expand Down Expand Up @@ -48,4 +48,4 @@ fun MyChart() {
The code above produces something like this:
<img src="https://raw.githubusercontent.com/overpas/compose-treemap-chart/master/img/sample_treemap.png" width="750">

For more advanced Kotlin Multiplatform samples check out the /sample directory
For more advanced Kotlin Multiplatform samples check out the [sample](https://github.com/overpas/compose-treemap-chart/tree/master/sample) directory
1 change: 1 addition & 0 deletions convention-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ plugins {

dependencies {
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
implementation(libs.maven.publish.plugin)
}
106 changes: 0 additions & 106 deletions convention-plugins/src/main/kotlin/publication.gradle.kts

This file was deleted.

50 changes: 50 additions & 0 deletions convention-plugins/src/main/kotlin/publish.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import com.vanniktech.maven.publish.SonatypeHost

plugins {
id("com.vanniktech.maven.publish")
}

mavenPublishing {
// Define coordinates for the published artifact
coordinates(
groupId = properties["lib.group"].toString().also { println(it) },
artifactId = project.name.also { println(it) },
version = properties["lib.version"].toString().also { println(it) },
)

// Configure POM metadata for the published artifact
pom {
name.set("Treemap Chart Compose")
description.set("Jetpack Compose (Multiplatform) treemap chart implementation")
url.set("https://github.com/overpas/compose-treemap-chart")

licenses {
license {
name.set("MIT")
url.set("https://github.com/overpas/compose-treemap-chart/blob/master/LICENSE.txt")
}
}

// Specify developers information
developers {
developer {
id.set("overpas")
name.set("Pavel Shurmilov")
email.set("[email protected]")
}
}

// Specify SCM information
scm {
connection.set("scm:git:github.com/overpas/compose-treemap-chart.git")
developerConnection.set("scm:git:ssh://github.com/overpas/compose-treemap-chart.git")
url.set("https://github.com/overpas/compose-treemap-chart/tree/master")
}
}

// Configure publishing to Maven Central
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)

// Enable GPG signing for all publications
signAllPublications()
}
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ jvm.version=17
android.minSdk=24
android.compileSdk=34
android.targetSdk=34
lib.version=0.1.2
lib.group=io.github.overpas
lib.version=0.1.3
lib.group=io.github.overpas

# For manual publication paste the necessary entries from local.properties here in order for maven-publish plugin to work
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ androidx-compose-ui-test = "1.7.4"
robolectric = "4.13"
# Other
detekt = '1.23.7'
maven-publish-plugin = "0.30.0"

[libraries]
# Kotlin
Expand Down Expand Up @@ -59,6 +60,8 @@ androidx-test-rules = { group = "androidx.test", name = "rules", version.ref = "
androidx-compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest", version.ref = "androidx-compose-ui-test" }
androidx-compose-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "androidx-compose-ui-test" }
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
# Other
maven-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "maven-publish-plugin" }

[plugins]
# Android
Expand Down
4 changes: 1 addition & 3 deletions treemap-chart-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ plugins {
alias(libs.plugins.compose)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.detekt)
id("publication")
id("publish")
}

group = properties["lib.group"].toString()
version = properties["lib.version"].toString()

println("group = $group, version = $version")

android {
namespace = "by.overpass.treemapchart.compose"
compileSdk = properties["android.compileSdk"].toString().toInt()
Expand Down
2 changes: 1 addition & 1 deletion treemap-chart/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
alias(libs.plugins.compose)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.detekt)
id("publication")
id("publish")
}

group = properties["lib.group"].toString()
Expand Down

0 comments on commit ad6383f

Please sign in to comment.