Skip to content

Commit d59fc2d

Browse files
authored
feat: Publish to GitHub (#104)
1 parent d910e5c commit d59fc2d

4 files changed

Lines changed: 83 additions & 29 deletions

File tree

.github/workflows/publish.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [ created ]
6+
7+
env:
8+
JAVA_VERSION: 17
9+
JAVA_DISTRO: 'temurin'
10+
11+
jobs:
12+
publish:
13+
name: Publish to GitHub Packages
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
steps:
20+
- uses: actions/checkout@v6
21+
- uses: actions/setup-java@v5
22+
with:
23+
java-version: ${{ env.JAVA_VERSION }}
24+
distribution: ${{ env.JAVA_DISTRO }}
25+
26+
- name: Publish to GitHub Packages
27+
run: ./gradlew publishAllPublicationsToGitHubPackagesRepository
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

composeApp/build.gradle.kts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,24 @@ kotlin {
3838
}
3939
}
4040

41+
applyDefaultHierarchyTemplate()
42+
4143
sourceSets {
42-
commonMain.dependencies {
43-
implementation(project(":generic-datastore"))
44-
implementation(project(":generic-datastore-compose"))
45-
implementation(libs.bundles.compose)
46-
implementation(libs.kotlinx.serialization.json)
47-
implementation(libs.androidx.lifecycle.viewmodel.compose)
44+
val commonMain by getting {
45+
dependencies {
46+
implementation(project(":generic-datastore"))
47+
implementation(project(":generic-datastore-compose"))
48+
implementation(libs.bundles.compose)
49+
implementation(libs.kotlinx.serialization.json)
50+
implementation(libs.androidx.lifecycle.viewmodel.compose)
51+
}
4852
}
4953

50-
androidMain.dependencies {
51-
implementation(libs.androidx.core.ktx)
52-
implementation(libs.activity.compose)
54+
val androidMain by getting {
55+
dependencies {
56+
implementation(libs.androidx.core.ktx)
57+
implementation(libs.activity.compose)
58+
}
5359
}
5460

5561
val desktopMain by getting {
@@ -58,6 +64,13 @@ kotlin {
5864
implementation(compose.desktop.currentOs)
5965
}
6066
}
67+
68+
val jvmCommon by creating {
69+
dependsOn(commonMain)
70+
}
71+
72+
androidMain.dependsOn(jvmCommon)
73+
desktopMain.dependsOn(jvmCommon)
6174
}
6275

6376
compilerOptions {

generic-datastore-compose/build.gradle.kts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ kotlin {
6060
}
6161

6262
publishing {
63+
repositories {
64+
maven {
65+
name = "GitHubPackages"
66+
url = uri("https://maven.pkg.github.com/arthurkun/generic-datastore")
67+
credentials {
68+
username = System.getenv("GITHUB_ACTOR")
69+
password = System.getenv("GITHUB_TOKEN")
70+
}
71+
}
72+
73+
// maven {
74+
// name = "JitPack"
75+
// url = uri("https://jitpack.io")
76+
// }
77+
}
6378
publications {
6479
withType<MavenPublication> {
6580
groupId = "com.github.arthurkun"

generic-datastore/build.gradle.kts

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,6 @@ plugins {
88
kotlin {
99
explicitApi()
1010

11-
// Workaround for https://youtrack.jetbrains.com/projects/KTIJ/issues/KTIJ-34430/Incorrect-resolution-of-platform-specific-APIs-in-commonMain-in-a-KMP-with-the-JVM-target-and-the-pluggable-target
12-
// issue with kotlin serialization with android jvm target in Android studio.
13-
// https://dev.to/rsicarelli/the-hidden-cost-of-default-hierarchy-templates-in-kotlin-multiplatform-256a
14-
// NEW UPDATE: It is still bad, adding the ios target stabilizes it, but it is still bad.
15-
// applyDefaultHierarchyTemplate()
16-
applyHierarchyTemplate {
17-
common {
18-
withAndroidTarget()
19-
withJvm()
20-
withCompilations { compilation ->
21-
compilation.target.platformType == org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType.androidJvm
22-
}
23-
group("ios") {
24-
withIosX64()
25-
withIosArm64()
26-
withIosSimulatorArm64()
27-
}
28-
}
29-
}
30-
3111
androidLibrary {
3212
namespace = "io.github.arthurkun.generic.datastore"
3313
compileSdk = libs.versions.compile.sdk.get().toInt()
@@ -56,6 +36,8 @@ kotlin {
5636
}
5737
}
5838

39+
applyDefaultHierarchyTemplate()
40+
5941
sourceSets {
6042
commonMain.dependencies {
6143
implementation(libs.coroutines.core)
@@ -95,6 +77,21 @@ kotlin {
9577
}
9678

9779
publishing {
80+
repositories {
81+
maven {
82+
name = "GitHubPackages"
83+
url = uri("https://maven.pkg.github.com/arthurkun/generic-datastore")
84+
credentials {
85+
username = System.getenv("GITHUB_ACTOR")
86+
password = System.getenv("GITHUB_TOKEN")
87+
}
88+
}
89+
90+
// maven {
91+
// name = "JitPack"
92+
// url = uri("https://jitpack.io")
93+
// }
94+
}
9895
publications {
9996
withType<MavenPublication> {
10097
groupId = "com.github.arthurkun"

0 commit comments

Comments
 (0)