Skip to content

Commit

Permalink
Merge branch 'main' into ANDROAPP-6097-Create-AssistChip-component
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAparicioAlbaAsenjo authored May 14, 2024
2 parents 08b45f5 + 619f443 commit a1eb925
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 68 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/continuous-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ name: Continuous deployment
on:
push:
branches:
- main
- develop

# Allows you to run this workflow manually from the Actions tab
Expand Down Expand Up @@ -36,7 +35,9 @@ jobs:

# Create publish to maven
- name: Publish to maven
run: ./gradlew publishAllPublicationsToSonatypeRepository
run: ./.github/workflows/scripts/publish-maven.sh
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_PRIVATE_KEY: ${{ secrets.PGP_PRIVATE_KEY }}
SIGNING_PASSWORD: ${{ secrets.PGP_PASSPHRASE }}
9 changes: 9 additions & 0 deletions .github/workflows/scripts/publish-maven.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set -x

branch=$(git rev-parse --abbrev-ref HEAD)

if [ "$branch" = "main" ]; then
./gradlew :designsystem:publishToSonatype closeAndReleaseSonatypeStagingRepository -PremoveSnapshotSuffix
else
./gradlew :designsystem:publishToSonatype
fi
15 changes: 15 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

group = "org.hisp.dhis.mobile"

plugins {
kotlin("multiplatform") apply false
id("com.android.application") apply false
id("com.android.library") apply false
id("org.jetbrains.compose") apply false
id("org.jlleitschuh.gradle.ktlint") version "11.5.1"
id("org.jetbrains.dokka") version "1.9.20"
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
}

allprojects {
Expand Down Expand Up @@ -67,3 +70,15 @@ subprojects {
}
}
}

val ossrhUsername: String? = System.getenv("OSSRH_USERNAME")
val ossrhPassword: String? = System.getenv("OSSRH_PASSWORD")

nexusPublishing {
this.repositories {
sonatype {
username.set(ossrhUsername)
password.set(ossrhPassword)
}
}
}
2 changes: 1 addition & 1 deletion convention-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ plugins {

repositories {
gradlePluginPortal() // To use 'maven-publish' and 'signing' plugins in our own plugin
}
}
15 changes: 15 additions & 0 deletions convention-plugins/src/main/kotlin/Props.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
object Props {
const val DESCRIPTION = "Compose Multiplatform DHIS2 Mobile UI components library"

const val REPOSITORY_SYSTEM = "GitHub"
const val REPOSITORY_URL = "https://github.com/dhis2/dhis2-mobile-ui"

const val AUTHOR_NAME = "Mobile team"
const val AUTHOR_EMAIL = "[email protected]"

const val ORGANIZATION_NAME = "UiO"
const val ORGANIZATION_URL = "http://www.dhis2.org"

const val LICENSE_NAME = "BSD-3-Clause"
const val LICENSE_URL = "https://opensource.org/license/bsd-3-clause/"
}
Original file line number Diff line number Diff line change
@@ -1,101 +1,72 @@
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.`maven-publish`
import org.gradle.kotlin.dsl.signing
import java.util.*

plugins {
`maven-publish`
signing
}

// Stub secrets to let the project sync and build without the publication values set up
ext["signing.keyId"] = null
ext["signing.password"] = null
ext["signing.secretKeyRingFile"] = null
ext["ossrhUsername"] = null
ext["ossrhPassword"] = null
val ossrhUsername: String? = System.getenv("OSSRH_USERNAME")
val ossrhPassword: String? = System.getenv("OSSRH_PASSWORD")
val signingPrivateKey: String? = System.getenv("SIGNING_PRIVATE_KEY")
val signingPassword: String? = System.getenv("SIGNING_PASSWORD")

// Grabbing secrets from local.properties file or from environment variables, which could be used on CI
val secretPropsFile = project.rootProject.file("local.properties")
if (secretPropsFile.exists()) {
secretPropsFile.reader().use {
Properties().apply {
load(it)
}
}.onEach { (name, value) ->
ext[name.toString()] = value
}
} else {
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
}
val dokkaHtml = tasks.findByName("dokkaHtml")!!

val javadocJar by tasks.registering(Jar::class) {
val dokkaHtmlJar = tasks.register<Jar>("dokkaHtmlJar") {
dependsOn(dokkaHtml)
from(dokkaHtml.outputs)
archiveClassifier.set("javadoc")
}

fun getExtraString(name: String) = ext[name]?.toString()

publishing {
// Configure maven central repository
repositories {
maven {
name = "sonatype"
setUrl("https://oss.sonatype.org/content/repositories/snapshots/")
credentials {
username = getExtraString("ossrhUsername")
password = getExtraString("ossrhPassword")
}
}
}

// Configure all publications
publications.withType<MavenPublication> {
// Stub javadoc.jar artifact
artifact(javadocJar.get())
artifact(dokkaHtmlJar)

// Provide artifacts information requited by Maven Central
pom {
name.set("DHIS2 Mobile Design system")
description.set("Compose Multiplatform DHIS2 Mobile UI components library")
url.set("https://github.com/dhis2/dhis2-mobile-ui")
description.set(Props.DESCRIPTION)
url.set(Props.REPOSITORY_URL)

licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
name.set(Props.LICENSE_NAME)
url.set(Props.LICENSE_URL)
}
}
organization {
name.set(Props.ORGANIZATION_NAME)
url.set(Props.ORGANIZATION_URL)
}
developers {
developer {
id.set("andresmr")
name.set("Andres")
email.set("[email protected]")
}
developer {
id.set("xavimolloy")
name.set("Xavi")
email.set("[email protected]")
}
developer {
id.set("DavidAparicioAlbaAsenjo")
name.set("David")
email.set("[email protected]")
name.set(Props.AUTHOR_NAME)
email.set(Props.AUTHOR_EMAIL)
organization.set(Props.ORGANIZATION_NAME)
organizationUrl.set(Props.ORGANIZATION_URL)
}
}
scm {
url.set("https://github.com/dhis2/dhis2-mobile-ui")
}
issueManagement {
system.set(Props.REPOSITORY_SYSTEM)
url.set(Props.REPOSITORY_URL)
}
}
}
}

// Signing artifacts. Signing.* extra properties values will be used
signing {
isRequired = false
setRequired({ !version.toString().endsWith("-SNAPSHOT") })
useInMemoryPgpKeys(signingPrivateKey, signingPassword)
sign(publishing.publications)
}
}

// Fix Gradle warning about signing tasks using publishing task outputs without explicit dependencies
// https://github.com/gradle/gradle/issues/26091
tasks.withType<AbstractPublishToMaven>().configureEach {
val signingTasks = tasks.withType<Sign>()
mustRunAfter(signingTasks)
}
10 changes: 9 additions & 1 deletion designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group = "org.hisp.dhis.mobile"
version = "0.2-SNAPSHOT"
group = "org.hisp.dhis.mobile"

plugins {
kotlin("multiplatform")
Expand All @@ -9,6 +9,14 @@ plugins {
id("app.cash.paparazzi").version("1.3.3")
}

/**
* Property from the Gradle command line. To remove the snapshot suffix from the version.
*/
if (project.hasProperty("removeSnapshotSuffix")) {
val mainVersion = (version as String).split("-SNAPSHOT")[0]
version = mainVersion
}

kotlin {
androidTarget {
publishLibraryVariants("release")
Expand Down

0 comments on commit a1eb925

Please sign in to comment.