Skip to content

Commit e2cb2e8

Browse files
committed
Merge branch 'master' into feature/kotlin-1.8.0
2 parents 288912e + 435de9a commit e2cb2e8

9 files changed

Lines changed: 163 additions & 4 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Cache Gradle
2+
description: Caches Gradle files
3+
runs:
4+
using: composite
5+
steps:
6+
- uses: actions/cache@v2
7+
with:
8+
path: |
9+
~/.gradle/caches
10+
~/.gradle/wrapper
11+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
12+
restore-keys: |
13+
${{ runner.os }}-gradle-
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Cache Konan
2+
description: Caches Konan files
3+
runs:
4+
using: composite
5+
steps:
6+
- uses: actions/cache@v2
7+
with:
8+
path: ~/.konan
9+
key: ${{ runner.os }}-konan-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
10+
restore-keys: |
11+
${{ runner.os }}-konan-
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Publish a Kotlin release
2+
on:
3+
push:
4+
tags:
5+
- 'v[0-9]+.[0-9]+.[0-9]+'
6+
- 'v[0-9]+.[0-9]+.[0-9]+-kotlin-[0-9]+.[0-9]+.[0-9]+'
7+
- 'v[0-9]+.[0-9]+.[0-9]+-kotlin-[0-9]+.[0-9]+.[0-9]+-Beta'
8+
- 'v[0-9]+.[0-9]+.[0-9]+-kotlin-[0-9]+.[0-9]+.[0-9]+-RC'
9+
- 'v[0-9]+.[0-9]+.[0-9]+-kotlin-[0-9]+.[0-9]+.[0-9]+-RC[0-9]+'
10+
- 'v[0-9]+.[0-9]+.[0-9]+-ALPHA-[0-9]+'
11+
- 'v[0-9]+.[0-9]+.[0-9]+-ALPHA-[0-9]+-kotlin-[0-9]+.[0-9]+.[0-9]+'
12+
- 'v[0-9]+.[0-9]+.[0-9]+-ALPHA-[0-9]+-kotlin-[0-9]+.[0-9]+.[0-9]+-Beta'
13+
- 'v[0-9]+.[0-9]+.[0-9]+-ALPHA-[0-9]+-kotlin-[0-9]+.[0-9]+.[0-9]+-RC'
14+
- 'v[0-9]+.[0-9]+.[0-9]+-ALPHA-[0-9]+-kotlin-[0-9]+.[0-9]+.[0-9]+-RC[0-9]+'
15+
jobs:
16+
publish-kotlin-libraries:
17+
runs-on: macos-12
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
- name: Gradle Wrapper Validation
22+
uses: gradle/wrapper-validation-action@v1
23+
- name: Setup JDK
24+
uses: actions/setup-java@v2
25+
with:
26+
distribution: 'zulu'
27+
java-version: '11'
28+
- name: Cache Gradle
29+
uses: ./.github/actions/cache-gradle
30+
- name: Cache Konan
31+
uses: ./.github/actions/cache-konan
32+
- name: Publish to Sonatype
33+
run: ./gradlew publishAllPublicationsToSonatypeRepository
34+
env:
35+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
36+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
37+
SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }}
38+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
39+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
A library that allows you to share ViewModels between Android and iOS.
44

5-
> **Warning**: this is still a WIP. Initial release coming soon 😁
5+
## Compatibility
6+
7+
The latest version of the library uses Kotlin version `1.7.21`.
8+
Compatibility versions for newer Kotlin versions are also available:
9+
10+
| Version | Version suffix | Kotlin | Coroutines |
11+
|--------------|------------------|:----------:|:----------:|
12+
| _latest_ | -kotlin-1.8.0-RC | 1.8.0-RC | 1.6.4 |
13+
| **_latest_** | **_no suffix_** | **1.7.21** | **1.6.4** |
614

715
## Kotlin
816

@@ -81,16 +89,18 @@ class TimeTravelFragment: Fragment(R.layout.fragment_time_travel) {
8189

8290
> **Note:** support for Jetpack Compose is coming soon.
8391
84-
8592
## Swift
8693

87-
Add the Swift package to your project:
94+
Add the Swift package to your `Package.swift` file:
8895
```swift
8996
dependencies: [
9097
.package(url: "https://github.com/rickclephas/KMM-ViewModel.git", from: "<version>")
9198
]
9299
```
93100

101+
Or add it in Xcode by going to `File` > `Add Packages...` and providing the URL:
102+
`https://github.com/rickclephas/KMM-ViewModel.git`.
103+
94104
Create a `KMMViewModel.swift` file with the following contents:
95105
```swift
96106
import KMMViewModelCore

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88

99
allprojects {
1010
group = "com.rickclephas.kmm"
11-
version = "0.1.0-SNAPSHOT"
11+
version = "1.0.0-ALPHA-1"
1212

1313
repositories {
1414
mavenCentral()

buildSrc/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
gradlePluginPortal()
7+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
plugins {
2+
`maven-publish`
3+
signing
4+
}
5+
6+
ext["signing.keyId"] = null
7+
ext["signing.password"] = null
8+
ext["signing.secretKey"] = null
9+
ext["signing.secretKeyRingFile"] = null
10+
ext["ossrhUsername"] = null
11+
ext["ossrhPassword"] = null
12+
val localPropsFile = project.rootProject.file("local.properties")
13+
if (localPropsFile.exists()) {
14+
localPropsFile.reader()
15+
.use { java.util.Properties().apply { load(it) } }
16+
.onEach { (name, value) -> ext[name.toString()] = value }
17+
} else {
18+
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
19+
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
20+
ext["signing.secretKey"] = System.getenv("SIGNING_SECRET_KEY")
21+
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
22+
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
23+
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
24+
}
25+
26+
val emptyJavadocJar by tasks.registering(Jar::class) {
27+
archiveClassifier.set("javadoc")
28+
}
29+
30+
fun getExtraString(name: String) = ext[name]?.toString()
31+
32+
publishing {
33+
repositories {
34+
maven {
35+
name = "sonatype"
36+
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
37+
credentials {
38+
username = getExtraString("ossrhUsername")
39+
password = getExtraString("ossrhPassword")
40+
}
41+
}
42+
}
43+
44+
publications.withType<MavenPublication> {
45+
artifact(emptyJavadocJar.get())
46+
47+
pom {
48+
name.set("KMM-ViewModel")
49+
description.set("Library to share Kotlin ViewModels with SwiftUI")
50+
url.set("https://github.com/rickclephas/KMM-ViewModel")
51+
licenses {
52+
license {
53+
name.set("MIT")
54+
url.set("https://opensource.org/licenses/MIT")
55+
}
56+
}
57+
developers {
58+
developer {
59+
id.set("rickclephas")
60+
name.set("Rick Clephas")
61+
email.set("rclephas@gmail.com")
62+
}
63+
}
64+
scm {
65+
url.set("https://github.com/rickclephas/KMM-ViewModel")
66+
}
67+
}
68+
}
69+
}
70+
71+
getExtraString("signing.keyId")?.let { keyId ->
72+
signing {
73+
getExtraString("signing.secretKey")?.let { secretKey ->
74+
useInMemoryPgpKeys(keyId, secretKey, getExtraString("signing.password"))
75+
}
76+
sign(publishing.publications)
77+
}
78+
}

gradlew

100644100755
File mode changed.

kmm-viewmodel-core/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
alias(libs.plugins.android.library)
44
@Suppress("DSL_SCOPE_VIOLATION")
55
alias(libs.plugins.kotlin.multiplatform)
6+
`kmm-viewmodel-publish`
67
}
78

89
kotlin {

0 commit comments

Comments
 (0)