Skip to content

Commit

Permalink
publishing shold work now
Browse files Browse the repository at this point in the history
  • Loading branch information
aenriii committed Nov 29, 2023
1 parent 11a27cb commit 0be0324
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 49 deletions.
43 changes: 38 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import java.text.SimpleDateFormat
import java.util.*

@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
alias(libs.plugins.android.library) apply false
Expand All @@ -18,12 +21,42 @@ buildscript {
}

allprojects {
group = "uninit.common"
version = "0.1.0"
}
group = "uninit"
extra["root-maven-url"] = "https://repo.uninit.dev/"
val ci = System.getenv("CI") != null
val isRelease = System.getenv("GITHUB_EVENT_NAME") == "release"

version = "0.0.1"
if (ci && !isRelease) {
version = "${version.toString()}-${SimpleDateFormat("YYYYMMdd").format(Date(System.currentTimeMillis()))}-${System.getenv("GITHUB_SHA").slice(0..6)}" // todo: add date
}
if (!ci) {
version = "${version.toString()}-LOCAL#${System.currentTimeMillis()}"
}

/*
* If SNAPSHOT:
* version = "VERSION-YYYYMMdd-HASH"
* If not CI:
* version = "VERSION-LOCAL#TIMESTAMP"
* If RELEASE:
* version = "VERSION"
*/

val mavenRepo: PublishingExtension.() -> Unit = {
repositories {
maven {
name = "uninit"
url = uri("${extra["root-maven-url"]}${if (ci) "snapshots" else "releases"}")
credentials {
username = "admin"
password = System.getenv("REPOSILITE_PASSWORD")
}
}
}
}

subprojects {
buildDir = file(rootProject.buildDir.absolutePath + "/" + project.name)
extra["maven-repository"] = mavenRepo
}

true // Needed to make the Suppress annotation work for the plugins block
30 changes: 7 additions & 23 deletions common-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ kotlin {
compileOnly(libs.koin.compose)

implementation(project(":common"))

}
resources.srcDirs("resources")
}
Expand Down Expand Up @@ -64,33 +65,16 @@ android {
jvmToolchain(17)
}
}

publishing {
var versionStr = project.version.toString()
val ci = System.getenv("CI") != null && System.getenv("GITHUB_EVENT_NAME") != "release"
var repo = "releases"
if (ci) {
val commitHash = System.getenv("GITHUB_SHA").slice(0..6)
versionStr += "-#$commitHash"
repo = "snapshots"
}
repositories {
maven {
name = "uninit"
url = uri("https://repo.uninit.dev/$repo")
credentials {
username = "admin"
password = System.getenv("REPOSILITE_PASSWORD")
}
}
@Suppress("UNCHECKED_CAST")
(extra["maven-repository"] as (PublishingExtension.() -> Unit)?)?.invoke(this)

}
publications {
create<MavenPublication>("uninit.common-compose") {
create<MavenPublication>("uninit.common.compose") {
groupId = "uninit"
artifactId = "common-compose"
version = versionStr
version = project.version.toString()
from(components["kotlin"])
}
}

}
}
27 changes: 6 additions & 21 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,33 +59,18 @@ android {
}

publishing {
var versionStr = project.version.toString()
val ci = System.getenv("CI") != null && System.getenv("GITHUB_EVENT_NAME") != "release"
var repo = "releases"
if (ci) {
val commitHash = System.getenv("GITHUB_SHA").slice(0..6)
versionStr += "-#$commitHash"
repo = "snapshots"
}
repositories {
maven {
name = "uninit"
url = uri("https://repo.uninit.dev/$repo")
credentials {
username = "admin"
password = System.getenv("REPOSILITE_PASSWORD")
}
}

}
@Suppress("UNCHECKED_CAST")
(extra["maven-repository"] as (PublishingExtension.() -> Unit)?)?.invoke(this)

publications {
create<MavenPublication>("uninit.common") {
groupId = "uninit"
artifactId = "common"
version = versionStr
version = project.version.toString()
from(components["kotlin"])
}
}

}


true

0 comments on commit 0be0324

Please sign in to comment.