Skip to content

Commit 095382d

Browse files
committed
Prepare release to Maven Central
### What's done: * Renamed project to kotlin-multiplatform-diff * Bump gradle version from 6.8.2 to 6.8.3, made gradlew executable, increased gradle memory limits * Bump kotlin version form 1.4.30 to 1.4.31 * Bump junit-jupiter-engine version from 5.0.0 to 5.7.1 * Introduced buildSrc * Added reckon plugin * Added RELEASING.md * Added release.yml * Added PublishingConfiguration.kt
1 parent 446cff3 commit 095382d

11 files changed

+244
-25
lines changed

.github/workflows/release.yml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Create release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
env:
8+
GPG_SEC: ${{ secrets.PGP_SEC }}
9+
GPG_PASSWORD: ${{ secrets.PGP_PASSWORD }}
10+
OSSRH_USERNAME: ${{ secrets.SONATYPE_USER }}
11+
OSSRH_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
12+
13+
jobs:
14+
release_linux:
15+
name: Build release on main platform (Linux)
16+
runs-on: ubuntu-20.04
17+
steps:
18+
- name: Checkout
19+
uses: actions/[email protected]
20+
- name: Set up JDK 11
21+
uses: actions/setup-java@v1
22+
with:
23+
java-version: 1.11
24+
- uses: burrunan/gradle-cache-action@v1
25+
name: Gradle release with caches caching
26+
with:
27+
arguments: publishToSonatype closeSonatypeStagingRepository
28+
gradle-version: wrapper
29+
- name: Create Github Release
30+
id: create_release
31+
uses: actions/create-release@v1
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
with:
35+
tag_name: ${{ github.ref }}
36+
release_name: Release ${{ github.ref }}
37+
draft: false
38+
prerelease: false
39+
release_macos:
40+
name: Build release on MacOS
41+
runs-on: macos-latest
42+
steps:
43+
- name: Checkout
44+
uses: actions/[email protected]
45+
- name: Set up JDK 11
46+
uses: actions/setup-java@v1
47+
with:
48+
java-version: 1.11
49+
- uses: burrunan/gradle-cache-action@v1
50+
name: Gradle release with caches caching
51+
with:
52+
arguments: publishToSonatype closeSonatypeStagingRepository
53+
gradle-version: wrapper
54+
release_windows:
55+
name: Build release on Windows
56+
runs-on: windows-latest
57+
steps:
58+
- name: Checkout
59+
uses: actions/[email protected]
60+
- name: Set up JDK 11
61+
uses: actions/setup-java@v1
62+
with:
63+
java-version: 1.11
64+
- uses: burrunan/gradle-cache-action@v1
65+
name: Gradle release with caches caching
66+
with:
67+
arguments: publishToSonatype closeSonatypeStagingRepository
68+
gradle-version: wrapper

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# kotlin-diff-utils
2-
![Build and test](https://github.com/petertrr/kotlin-diff-utils/workflows/Build%20and%20test/badge.svg)
3-
[![License](https://img.shields.io/github/license/petertrr/kotlin-diff-utils)](https://github.com/petertrr/kotlin-diff-utils/blob/main/LICENSE)
4-
[![codecov](https://codecov.io/gh/petertrr/kotlin-diff-utils/branch/main/graph/badge.svg)](https://codecov.io/gh/petertrr/kotlin-diff-utils)
1+
# kotlin-multiplatform-diff
2+
![Build and test](https://github.com/petertrr/kotlin-multiplatform-diff/workflows/Build%20and%20test/badge.svg)
3+
[![License](https://img.shields.io/github/license/petertrr/kotlin-multiplatform-diff)](https://github.com/petertrr/kotlin-multiplatform-diff/blob/main/LICENSE)
4+
[![codecov](https://codecov.io/gh/petertrr/kotlin-multiplatform-diff/branch/main/graph/badge.svg)](https://codecov.io/gh/petertrr/kotlin-multiplatform-diff)
55

66
This is a port of [java-diff-utils](https://github.com/java-diff-utils/java-diff-utils) to kotlin
77
with multiplatform support. All credit for the implementation goes to original authors.
@@ -18,4 +18,5 @@ Currently, artifacts for the following platforms are supported:
1818
* JVM
1919
* JS (both browser and Node.js)
2020
* LinuxX64
21-
* MingwX64
21+
* MingwX64
22+
* MacosX64

RELEASING.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1. Push a new git tag of a format 'v*', e.g. v1.0.0
2+
2. Github Actions workflow will start, building release and pushing it to maven central. It will then create a github release.
3+
3. Update github release with release notes.

build.gradle.kts

+12-17
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurrentOperatingSystem
1+
import io.github.petertrr.configurePublishing
2+
import io.github.petertrr.configureVersioning
23
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest
34

45
plugins {
5-
kotlin("multiplatform") version "1.4.30"
6+
kotlin("multiplatform") version "1.4.31"
67
jacoco
7-
id("maven-publish")
8+
id("com.github.ben-manes.versions") version "0.38.0"
89
}
910

11+
configureVersioning()
1012
group = "io.github.petertrr"
11-
version = "0.1.0-SNAPSHOT"
13+
description = "A multiplatform Kotlin library for calculating text differences"
1214

1315
repositories {
1416
mavenCentral()
@@ -18,17 +20,14 @@ kotlin {
1820
explicitApi()
1921

2022
jvm()
21-
js(IR) {
23+
js(BOTH) {
2224
browser()
2325
nodejs()
2426
}
2527
// setup native compilation
26-
val os = getCurrentOperatingSystem()
27-
val hostTarget = when {
28-
os.isLinux -> linuxX64()
29-
os.isWindows -> mingwX64()
30-
else -> throw GradleException("Host OS '${os.name}' is not supported in Kotlin/Native $project.")
31-
}
28+
linuxX64()
29+
mingwX64()
30+
macosX64()
3231

3332
sourceSets {
3433
val commonTest by getting {
@@ -41,7 +40,7 @@ kotlin {
4140
val jvmTest by getting {
4241
dependencies {
4342
implementation(kotlin("test-junit5"))
44-
implementation("org.junit.jupiter:junit-jupiter-engine:5.0.0")
43+
implementation("org.junit.jupiter:junit-jupiter-engine:5.7.1")
4544
}
4645
}
4746
val jsTest by getting {
@@ -52,11 +51,7 @@ kotlin {
5251
}
5352
}
5453

55-
publishing {
56-
repositories {
57-
mavenLocal()
58-
}
59-
}
54+
configurePublishing()
6055

6156
tasks.withType<KotlinJvmTest> {
6257
useJUnitPlatform()

buildSrc/build.gradle.kts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
gradlePluginPortal()
7+
mavenCentral()
8+
jcenter()
9+
}
10+
11+
dependencies {
12+
implementation("org.ajoberstar.reckon:reckon-gradle:0.13.0")
13+
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.20")
14+
implementation("io.github.gradle-nexus:publish-plugin:1.0.0")
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
package io.github.petertrr
2+
3+
import org.gradle.api.Project
4+
import io.github.gradlenexus.publishplugin.NexusPublishPlugin
5+
import io.github.gradlenexus.publishplugin.NexusPublishExtension
6+
import org.gradle.api.publish.PublishingExtension
7+
import org.gradle.api.publish.maven.MavenPublication
8+
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
9+
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
10+
import org.gradle.api.tasks.bundling.Jar
11+
import org.gradle.kotlin.dsl.*
12+
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
13+
import org.gradle.plugins.signing.SigningExtension
14+
import org.gradle.plugins.signing.SigningPlugin
15+
16+
fun Project.configurePublishing() {
17+
apply<MavenPublishPlugin>()
18+
apply<SigningPlugin>()
19+
apply<NexusPublishPlugin>()
20+
21+
// If present, set properties from env variables. If any are absent, release will fail.
22+
System.getenv("OSSRH_USERNAME")?.let {
23+
extra.set("sonatypeUsername", it)
24+
}
25+
System.getenv("OSSRH_PASSWORD")?.let {
26+
extra.set("sonatypePassword", it)
27+
}
28+
System.getenv("GPG_SEC")?.let {
29+
extra.set("signingKey", it)
30+
}
31+
System.getenv("GPG_PASSWORD")?.let {
32+
extra.set("signingPassword", it)
33+
}
34+
35+
configurePublications()
36+
// https://kotlinlang.org/docs/mpp-publish-lib.html#avoid-duplicate-publications
37+
val publicationsFromMainHost = listOf("jvm", "js", "kotlinMultiplatform")
38+
configure<PublishingExtension> {
39+
publications {
40+
matching { it.name in publicationsFromMainHost }.all {
41+
val targetPublication = this@all
42+
tasks.withType<AbstractPublishToMaven>()
43+
.matching { it.publication == targetPublication }
44+
.configureEach {
45+
onlyIf {
46+
// main publishing CI job is executed on Linux host
47+
DefaultNativePlatform.getCurrentOperatingSystem().isLinux
48+
}
49+
}
50+
}
51+
}
52+
}
53+
54+
if (hasProperty("signingKey")) {
55+
configureSigning()
56+
}
57+
if (hasProperty("sonatypeUsername")) {
58+
configureNexusPublishing()
59+
}
60+
}
61+
62+
private fun Project.configurePublications() {
63+
val dokkaJar = tasks.create<Jar>("dokkaJar") {
64+
group = "documentation"
65+
archiveClassifier.set("javadoc")
66+
from(tasks.findByName("dokkaHtml"))
67+
}
68+
configure<PublishingExtension> {
69+
repositories {
70+
mavenLocal()
71+
}
72+
publications.withType<MavenPublication>().forEach { publication ->
73+
publication.artifact(dokkaJar)
74+
publication.pom {
75+
name.set(project.name)
76+
description.set(project.description ?: project.name)
77+
url.set("https://github.com/petertrr/kotlin-multiplatform-diff")
78+
licenses {
79+
license {
80+
name.set("The Apache Software License, Version 2.0")
81+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
82+
distribution.set("repo")
83+
}
84+
}
85+
developers {
86+
developer {
87+
id.set("petertrr")
88+
name.set("Petr Trifanov")
89+
email.set("[email protected]")
90+
}
91+
}
92+
scm {
93+
url.set("https://github.com/petertrr/kotlin-multiplatform-diff")
94+
connection.set("scm:git:git://github.com/petertrr/kotlin-multiplatform-diff.git")
95+
}
96+
}
97+
}
98+
}
99+
}
100+
101+
private fun Project.configureSigning() {
102+
configure<SigningExtension> {
103+
useInMemoryPgpKeys(property("signingKey") as String?, property("signingPassword") as String?)
104+
logger.lifecycle("The following publications are getting signed: ${extensions.getByType<PublishingExtension>().publications.map { it.name }}")
105+
sign(*extensions.getByType<PublishingExtension>().publications.toTypedArray())
106+
}
107+
}
108+
109+
private fun Project.configureNexusPublishing() {
110+
configure<NexusPublishExtension> {
111+
repositories {
112+
sonatype { //only for users registered in Sonatype after 24 Feb 2021
113+
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
114+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
115+
username.set(property("sonatypeUsername") as String)
116+
password.set(property("sonatypePassword") as String)
117+
}
118+
}
119+
}
120+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.github.petertrr
2+
3+
import org.ajoberstar.reckon.gradle.ReckonExtension
4+
import org.ajoberstar.reckon.gradle.ReckonPlugin
5+
import org.gradle.api.Project
6+
import org.gradle.kotlin.dsl.apply
7+
import org.gradle.kotlin.dsl.configure
8+
9+
fun Project.configureVersioning() {
10+
apply<ReckonPlugin>()
11+
12+
configure<ReckonExtension> {
13+
scopeFromProp()
14+
stageFromProp("alpha", "rc", "final") // version string will be based on last commit; when checking out a tag, that tag will be used
15+
}
16+
}

gradle.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
kotlin.code.style=official
1+
kotlin.code.style=official
2+
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

100644100755
File mode changed.

settings.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = "kotlin-diff-utils"
1+
rootProject.name = "kotlin-multiplatform-diff"

0 commit comments

Comments
 (0)