diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..3de1260 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,53 @@ +name: Publish to Maven Central + +on: + push: + branches: [ "master" ] + +jobs: + publish: + name: Build and publish to Maven Central + runs-on: macos-latest + timeout-minutes: 60 + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: '17' + + - name: Install GPG + env: + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + run: | + brew install gpg + echo "$SIGNING_KEY" | gpg --dearmor > ${HOME}/secring.gpg + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Add Gradle Properties + env: + MAVEN_CENTRAL_USER_NAME: ${{ secrets.MAVEN_CENTRAL_USER_NAME }} + MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + 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 \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index eeb760c..4db2d2f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,6 +7,7 @@ plugins { alias(libs.plugins.kotlinMultiplatform) apply false alias(libs.plugins.spotless) apply false alias(libs.plugins.mokkery) apply false + alias(libs.plugins.maven.publish) apply false } subprojects { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 35ee3c8..a749972 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,4 +1,5 @@ [versions] +input-engine = "2.0.1" activityKtx = "1.10.1" agp = "8.11.1" androidx-activity = "1.10.1" @@ -11,6 +12,7 @@ lifecycleViewmodelCompose = "2.9.1" spotless = "7.1.0" uiTestJunit4 = "1.8.3" mokkery = "2.9.0" +maven-publish = "0.34.0" [libraries] androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" } @@ -32,5 +34,6 @@ composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "k kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "composeMultiplatform" } +maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish" } spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } mokkery = { id = "dev.mokkery", version.ref = "mokkery" } diff --git a/input-engine/build.gradle.kts b/input-engine/build.gradle.kts index 18a918e..1e59c73 100644 --- a/input-engine/build.gradle.kts +++ b/input-engine/build.gradle.kts @@ -9,6 +9,7 @@ plugins { alias(libs.plugins.composeCompiler) alias(libs.plugins.kotlinSerialization) alias(libs.plugins.mokkery) + alias(libs.plugins.maven.publish) } kotlin { @@ -21,6 +22,8 @@ kotlin { @OptIn(ExperimentalKotlinGradlePluginApi::class) instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + publishLibraryVariants("release") + dependencies { androidTestImplementation(libs.androidx.ui.test.junit4.android) androidTestImplementation(libs.androidx.ui.test.manifest) @@ -120,3 +123,59 @@ compose.resources { packageOfResClass = "de.tillhub.inputengine.resources" generateResClass = auto } + +mavenPublishing { + // Define coordinates for the published artifact + coordinates( + groupId = "io.github.tillhub", + artifactId = "input-engine", + version = + libs.versions.input.engine + .get(), + ) + + // Configure POM metadata for the published artifact + pom { + name.set("Input Engine") + description.set("Kotlin MultiPlatform Library which allows easy customisable UI inputs for money, quantity, percentage & PIN.") + inceptionYear.set("2025") + url.set("https://github.com/tillhub/input-engine") + + licenses { + license { + name.set("MIT") + url.set("https://opensource.org/licenses/MIT") + } + } + + // Specify developers information + developers { + developer { + id.set("djordjeh") + name.set("Đorđe Hrnjez") + email.set("dorde.hrnjez@unzer.com") + } + developer { + id.set("SloInfinity") + name.set("Martin Sirok") + email.set("m.sirok.ext@unzer.com") + } + developer { + id.set("shekar-allam") + name.set("Chandrashekar Allam") + email.set("chandrashekar.allam@unzer.com") + } + } + + // Specify SCM information + scm { + url.set("https://github.com/tillhub/input-engine") + } + } + + // Configure publishing to Maven Central + publishToMavenCentral() + + // Enable GPG signing for all publications + signAllPublications() +}