Skip to content

Commit f21ed9d

Browse files
committed
publishing
1 parent 2aaf4f7 commit f21ed9d

16 files changed

Lines changed: 213 additions & 15 deletions

File tree

.github/scripts/decrypt_secret.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
# Decrypt the file
4+
# --batch to prevent interactive command --yes to assume "yes" for questions
5+
6+
gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" \
7+
--output ./8257B447.gpg ./.github/secrets/8257B447.gpg.gpg
8+
9+
gpg --quiet --batch --yes --decrypt --passphrase="$LARGE_SECRET_PASSPHRASE" \
10+
--output ./local.properties ./.github/secrets/local.properties.gpg

.github/secrets/8257B447.gpg.gpg

4.95 KB
Binary file not shown.

.github/secrets/local.properties.gpg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
� �}��c�����F�n�H9�рf�9��t[v�#h*�����R�y��E �:SчC4�Y�\���Ρ��{��b�'���w%��6���6�:3:^ ���A�#�O�'C���L�g�~�����'�W��]���qIc|�B�-��;z.�����sPK8zB��:�P����gv��P�9�����2�t�:) �i���,�=K���jV�

.github/workflows/build_only.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Build CI
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
tags-ignore:
8+
- '**'
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build_job:
14+
name: Build (Unit-tests)
15+
runs-on: macos-latest
16+
steps:
17+
- uses: actions/checkout@v1
18+
- name: Cache gradle
19+
uses: actions/cache@v1
20+
with:
21+
path: ~/.gradle/caches
22+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
23+
restore-keys: |
24+
${{ runner.os }}-gradle-
25+
- name: Decrypt large secret
26+
run: ./.github/scripts/decrypt_secret.sh
27+
env:
28+
LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}
29+
- name: Set up JDK 17
30+
uses: actions/setup-java@v1
31+
with:
32+
java-version: 17
33+
- name: Build
34+
run: ./gradlew build
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build & Publish CI/CD
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
build_unit_test_publish_job:
10+
name: Build -> Unit-test -> Publish
11+
runs-on: macos-latest
12+
steps:
13+
- uses: actions/checkout@v1
14+
- name: Cache gradle
15+
uses: actions/cache@v1
16+
with:
17+
path: ~/.gradle/caches
18+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
19+
restore-keys: |
20+
${{ runner.os }}-gradle-
21+
- name: Decrypt large secret
22+
run: ./.github/scripts/decrypt_secret.sh
23+
env:
24+
LARGE_SECRET_PASSPHRASE: ${{ secrets.LARGE_SECRET_PASSPHRASE }}
25+
- name: Set up JDK 17
26+
uses: actions/setup-java@v1
27+
with:
28+
java-version: 17
29+
- name: Build
30+
run: ./gradlew build
31+
- name: Publish
32+
run: ./gradlew publishAllPublicationsToSonatypeRepository --max-workers 1 closeAndReleaseRepository

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*.iml
22
.gradle
33
/local.properties
4+
/8257B447.gpg
45
/.idea
56
.DS_Store
67
build

README.MD

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ val diff: Duration = networkTime - systemTime
1818
```
1919
### Synchronization
2020
When running the application, it is necessary to synchronize the time with the network using the platform code function:
21-
```kotlin
22-
Clock.Network.sync()
23-
```
24-
For example, on Android:
21+
- Android:
2522
```kotlin
2623
class App : Application() {
2724
override fun onCreate() {
@@ -30,6 +27,23 @@ class App : Application() {
3027
}
3128
}
3229
```
30+
- iOS:
31+
```swift
32+
@main
33+
struct iosApp: App {
34+
init() {
35+
Clock.Network.sync()
36+
}
37+
var body: some Scene { ... }
38+
}
39+
```
40+
- Desktop JVM:
41+
```kotlin
42+
fun main() {
43+
Clock.Network.sync()
44+
...
45+
}
46+
```
3347
### Installation
3448
The latest release is available on [Maven Central](https://repo1.maven.org/maven2/io/github/softartdev/kronos/).
3549
1. Add the Maven Central repository if it is not already there:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
`kotlin-dsl` // Is needed to turn our build logic written in Kotlin into the Gradle Plugin
3+
}
4+
5+
repositories {
6+
gradlePluginPortal() // To use 'maven-publish' and 'signing' plugins in our own plugin
7+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import org.gradle.api.publish.maven.MavenPublication
2+
import org.gradle.api.tasks.bundling.Jar
3+
import org.gradle.kotlin.dsl.`maven-publish`
4+
import org.gradle.kotlin.dsl.signing
5+
import java.util.*
6+
7+
plugins {
8+
`maven-publish`
9+
signing
10+
}
11+
// Stub secrets to let the project sync and build without the publication values set up
12+
ext["signing.keyId"] = null
13+
ext["signing.password"] = null
14+
ext["signing.secretKeyRingFile"] = null
15+
ext["ossrhUsername"] = null
16+
ext["ossrhPassword"] = null
17+
18+
// Grabbing secrets from local.properties file or from environment variables, which could be used on CI
19+
val secretPropsFile = project.rootProject.file("local.properties")
20+
if (secretPropsFile.exists()) {
21+
secretPropsFile.reader().use {
22+
Properties().apply {
23+
load(it)
24+
}
25+
}.onEach { (name, value) ->
26+
ext[name.toString()] = value
27+
}
28+
} else {
29+
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
30+
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
31+
ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE")
32+
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
33+
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
34+
}
35+
ext["signing.secretKeyRingFile"] = "../${ext["signing.secretKeyRingFile"]}" // path from module
36+
val javadocJar by tasks.registering(Jar::class) {
37+
archiveClassifier.set("javadoc")
38+
}
39+
fun getExtraString(name: String) = ext[name]?.toString()
40+
41+
publishing {
42+
// Configure maven central repository
43+
repositories {
44+
maven {
45+
name = "sonatype"
46+
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
47+
credentials {
48+
username = getExtraString("ossrhUsername")
49+
password = getExtraString("ossrhPassword")
50+
}
51+
}
52+
}
53+
// Configure all publications
54+
publications.withType<MavenPublication> {
55+
// Stub javadoc.jar artifact
56+
artifact(javadocJar.get())
57+
// Provide artifacts information requited by Maven Central
58+
pom {
59+
name.set("Kronos Multiplatform Library")
60+
description.set("Kotlin Multiplatform SNTP library")
61+
url.set("https://github.com/softartdev/Kronos-Multiplatform")
62+
63+
licenses {
64+
license {
65+
name.set("MIT")
66+
url.set("https://opensource.org/licenses/MIT")
67+
}
68+
}
69+
developers {
70+
developer {
71+
id.set("softartdev")
72+
name.set("Artur Babichev")
73+
email.set("artik222012@gmail.com")
74+
}
75+
}
76+
scm {
77+
url.set("https://github.com/softartdev/Kronos-Multiplatform")
78+
}
79+
}
80+
}
81+
}
82+
83+
// Signing artifacts. Signing.* extra properties values will be used
84+
signing {
85+
sign(publishing.publications)
86+
}

gradle.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Gradle
2-
org.gradle.jvmargs=-Xmx16g -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx16g" -XX:+UseParallelGC
2+
org.gradle.jvmargs=-Xmx16g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx16g" -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g
33
org.gradle.parallel=true
44
org.gradle.daemon=true
55
org.gradle.configureondemand=true
@@ -18,3 +18,6 @@ kotlin.native.cacheKind=none
1818

1919
#Android
2020
android.useAndroidX=true
21+
android.nonTransitiveRClass=true
22+
android.nonFinalResIds=true
23+
android.defaults.buildfeatures.buildconfig=true

0 commit comments

Comments
 (0)