Skip to content

Commit

Permalink
Prepare release to Maven Central
Browse files Browse the repository at this point in the history
### 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
  • Loading branch information
petertrr committed Mar 13, 2021
1 parent 446cff3 commit 095382d
Show file tree
Hide file tree
Showing 11 changed files with 244 additions and 25 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Create release

on:
push:
tags:
- 'v*'
env:
GPG_SEC: ${{ secrets.PGP_SEC }}
GPG_PASSWORD: ${{ secrets.PGP_PASSWORD }}
OSSRH_USERNAME: ${{ secrets.SONATYPE_USER }}
OSSRH_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}

jobs:
release_linux:
name: Build release on main platform (Linux)
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.11
- uses: burrunan/gradle-cache-action@v1
name: Gradle release with caches caching
with:
arguments: publishToSonatype closeSonatypeStagingRepository
gradle-version: wrapper
- name: Create Github Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
release_macos:
name: Build release on MacOS
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.11
- uses: burrunan/gradle-cache-action@v1
name: Gradle release with caches caching
with:
arguments: publishToSonatype closeSonatypeStagingRepository
gradle-version: wrapper
release_windows:
name: Build release on Windows
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.11
- uses: burrunan/gradle-cache-action@v1
name: Gradle release with caches caching
with:
arguments: publishToSonatype closeSonatypeStagingRepository
gradle-version: wrapper
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# kotlin-diff-utils
![Build and test](https://github.com/petertrr/kotlin-diff-utils/workflows/Build%20and%20test/badge.svg)
[![License](https://img.shields.io/github/license/petertrr/kotlin-diff-utils)](https://github.com/petertrr/kotlin-diff-utils/blob/main/LICENSE)
[![codecov](https://codecov.io/gh/petertrr/kotlin-diff-utils/branch/main/graph/badge.svg)](https://codecov.io/gh/petertrr/kotlin-diff-utils)
# kotlin-multiplatform-diff
![Build and test](https://github.com/petertrr/kotlin-multiplatform-diff/workflows/Build%20and%20test/badge.svg)
[![License](https://img.shields.io/github/license/petertrr/kotlin-multiplatform-diff)](https://github.com/petertrr/kotlin-multiplatform-diff/blob/main/LICENSE)
[![codecov](https://codecov.io/gh/petertrr/kotlin-multiplatform-diff/branch/main/graph/badge.svg)](https://codecov.io/gh/petertrr/kotlin-multiplatform-diff)

This is a port of [java-diff-utils](https://github.com/java-diff-utils/java-diff-utils) to kotlin
with multiplatform support. All credit for the implementation goes to original authors.
Expand All @@ -18,4 +18,5 @@ Currently, artifacts for the following platforms are supported:
* JVM
* JS (both browser and Node.js)
* LinuxX64
* MingwX64
* MingwX64
* MacosX64
3 changes: 3 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1. Push a new git tag of a format 'v*', e.g. v1.0.0
2. Github Actions workflow will start, building release and pushing it to maven central. It will then create a github release.
3. Update github release with release notes.
29 changes: 12 additions & 17 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurrentOperatingSystem
import io.github.petertrr.configurePublishing
import io.github.petertrr.configureVersioning
import org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest

plugins {
kotlin("multiplatform") version "1.4.30"
kotlin("multiplatform") version "1.4.31"
jacoco
id("maven-publish")
id("com.github.ben-manes.versions") version "0.38.0"
}

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

repositories {
mavenCentral()
Expand All @@ -18,17 +20,14 @@ kotlin {
explicitApi()

jvm()
js(IR) {
js(BOTH) {
browser()
nodejs()
}
// setup native compilation
val os = getCurrentOperatingSystem()
val hostTarget = when {
os.isLinux -> linuxX64()
os.isWindows -> mingwX64()
else -> throw GradleException("Host OS '${os.name}' is not supported in Kotlin/Native $project.")
}
linuxX64()
mingwX64()
macosX64()

sourceSets {
val commonTest by getting {
Expand All @@ -41,7 +40,7 @@ kotlin {
val jvmTest by getting {
dependencies {
implementation(kotlin("test-junit5"))
implementation("org.junit.jupiter:junit-jupiter-engine:5.0.0")
implementation("org.junit.jupiter:junit-jupiter-engine:5.7.1")
}
}
val jsTest by getting {
Expand All @@ -52,11 +51,7 @@ kotlin {
}
}

publishing {
repositories {
mavenLocal()
}
}
configurePublishing()

tasks.withType<KotlinJvmTest> {
useJUnitPlatform()
Expand Down
15 changes: 15 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
mavenCentral()
jcenter()
}

dependencies {
implementation("org.ajoberstar.reckon:reckon-gradle:0.13.0")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.20")
implementation("io.github.gradle-nexus:publish-plugin:1.0.0")
}
120 changes: 120 additions & 0 deletions buildSrc/src/main/kotlin/io/github/petertrr/PublishingConfiguration.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package io.github.petertrr

import org.gradle.api.Project
import io.github.gradlenexus.publishplugin.NexusPublishPlugin
import io.github.gradlenexus.publishplugin.NexusPublishExtension
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.*
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.gradle.plugins.signing.SigningExtension
import org.gradle.plugins.signing.SigningPlugin

fun Project.configurePublishing() {
apply<MavenPublishPlugin>()
apply<SigningPlugin>()
apply<NexusPublishPlugin>()

// If present, set properties from env variables. If any are absent, release will fail.
System.getenv("OSSRH_USERNAME")?.let {
extra.set("sonatypeUsername", it)
}
System.getenv("OSSRH_PASSWORD")?.let {
extra.set("sonatypePassword", it)
}
System.getenv("GPG_SEC")?.let {
extra.set("signingKey", it)
}
System.getenv("GPG_PASSWORD")?.let {
extra.set("signingPassword", it)
}

configurePublications()
// https://kotlinlang.org/docs/mpp-publish-lib.html#avoid-duplicate-publications
val publicationsFromMainHost = listOf("jvm", "js", "kotlinMultiplatform")
configure<PublishingExtension> {
publications {
matching { it.name in publicationsFromMainHost }.all {
val targetPublication = this@all
tasks.withType<AbstractPublishToMaven>()
.matching { it.publication == targetPublication }
.configureEach {
onlyIf {
// main publishing CI job is executed on Linux host
DefaultNativePlatform.getCurrentOperatingSystem().isLinux
}
}
}
}
}

if (hasProperty("signingKey")) {
configureSigning()
}
if (hasProperty("sonatypeUsername")) {
configureNexusPublishing()
}
}

private fun Project.configurePublications() {
val dokkaJar = tasks.create<Jar>("dokkaJar") {
group = "documentation"
archiveClassifier.set("javadoc")
from(tasks.findByName("dokkaHtml"))
}
configure<PublishingExtension> {
repositories {
mavenLocal()
}
publications.withType<MavenPublication>().forEach { publication ->
publication.artifact(dokkaJar)
publication.pom {
name.set(project.name)
description.set(project.description ?: project.name)
url.set("https://github.com/petertrr/kotlin-multiplatform-diff")
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("petertrr")
name.set("Petr Trifanov")
email.set("[email protected]")
}
}
scm {
url.set("https://github.com/petertrr/kotlin-multiplatform-diff")
connection.set("scm:git:git://github.com/petertrr/kotlin-multiplatform-diff.git")
}
}
}
}
}

private fun Project.configureSigning() {
configure<SigningExtension> {
useInMemoryPgpKeys(property("signingKey") as String?, property("signingPassword") as String?)
logger.lifecycle("The following publications are getting signed: ${extensions.getByType<PublishingExtension>().publications.map { it.name }}")
sign(*extensions.getByType<PublishingExtension>().publications.toTypedArray())
}
}

private fun Project.configureNexusPublishing() {
configure<NexusPublishExtension> {
repositories {
sonatype { //only for users registered in Sonatype after 24 Feb 2021
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(property("sonatypeUsername") as String)
password.set(property("sonatypePassword") as String)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.github.petertrr

import org.ajoberstar.reckon.gradle.ReckonExtension
import org.ajoberstar.reckon.gradle.ReckonPlugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure

fun Project.configureVersioning() {
apply<ReckonPlugin>()

configure<ReckonExtension> {
scopeFromProp()
stageFromProp("alpha", "rc", "final") // version string will be based on last commit; when checking out a tag, that tag will be used
}
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
kotlin.code.style=official
kotlin.code.style=official
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Empty file modified gradlew
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = "kotlin-diff-utils"
rootProject.name = "kotlin-multiplatform-diff"

0 comments on commit 095382d

Please sign in to comment.