diff --git a/RELEASE.md b/RELEASE.md index f6c613a2f8..c9fd83fb8e 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -59,10 +59,9 @@ To release new `` of `kotlinx-coroutines`: (make sure you have [Docker](https://www.docker.com/) installed first):
`site/deploy.sh push` -4. In [Bintray](https://bintray.com/kotlin/kotlinx/kotlinx.coroutines) admin interface: - * Publish artifacts of the new version. - * Wait until newly published version becomes the most recent. - * Sync to Maven Central. +4. In [Nexus](https://oss.sonatype.org/#stagingRepositories) admin interface: + * Close the repository and wait for it to verify. + * Release the repository. 5. Announce new release in [Slack](https://kotlinlang.slack.com) diff --git a/buildSrc/src/main/kotlin/MavenCentral.kt b/buildSrc/src/main/kotlin/MavenCentral.kt deleted file mode 100644 index 3efaf33f1c..0000000000 --- a/buildSrc/src/main/kotlin/MavenCentral.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -@file:Suppress("UnstableApiUsage") - -import org.gradle.api.Project -import org.gradle.api.publish.maven.MavenPom - -// Pom configuration - -fun MavenPom.configureMavenCentralMetadata(project: Project) { - name by project.name - description by "Coroutines support libraries for Kotlin" - url by "https://github.com/Kotlin/kotlinx.coroutines" - - licenses { - license { - name by "The Apache Software License, Version 2.0" - url by "https://www.apache.org/licenses/LICENSE-2.0.txt" - distribution by "repo" - } - } - - developers { - developer { - id by "JetBrains" - name by "JetBrains Team" - organization by "JetBrains" - organizationUrl by "https://www.jetbrains.com" - } - } - - scm { - url by "https://github.com/Kotlin/kotlinx.coroutines" - } -} diff --git a/buildSrc/src/main/kotlin/Publishing.kt b/buildSrc/src/main/kotlin/Publishing.kt new file mode 100644 index 0000000000..55c7a8f298 --- /dev/null +++ b/buildSrc/src/main/kotlin/Publishing.kt @@ -0,0 +1,93 @@ +/* + * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +@file:Suppress("UnstableApiUsage") + +import org.gradle.api.Project +import org.gradle.api.artifacts.dsl.* +import org.gradle.api.publish.maven.* +import org.gradle.plugins.signing.* +import java.net.* + +// Pom configuration + +fun MavenPom.configureMavenCentralMetadata(project: Project) { + name by project.name + description by "Coroutines support libraries for Kotlin" + url by "https://github.com/Kotlin/kotlinx.coroutines" + + licenses { + license { + name by "The Apache Software License, Version 2.0" + url by "https://www.apache.org/licenses/LICENSE-2.0.txt" + distribution by "repo" + } + } + + developers { + developer { + id by "JetBrains" + name by "JetBrains Team" + organization by "JetBrains" + organizationUrl by "https://www.jetbrains.com" + } + } + + scm { + url by "https://github.com/Kotlin/kotlinx.coroutines" + } +} + +fun mavenRepositoryUri(): URI { + // TODO -SNAPSHOT detection can be made here as well + val repositoryId: String? = System.getenv("libs.repository.id") + return if (repositoryId == null) { + // Using implicitly created staging, for MPP it's likely to be a mistake because + // publication on TeamCity will create 3 independent staging repositories + System.err.println("Warning: using an implicitly created staging for coroutines") + URI("https://oss.sonatype.org/service/local/staging/deploy/maven2/") + } else { + URI("https://oss.sonatype.org/service/local/staging/deployByRepositoryId/$repositoryId") + } +} + +fun configureMavenPublication(rh: RepositoryHandler, project: Project) { + rh.maven { + url = mavenRepositoryUri() + credentials { + username = project.getSensitiveProperty("libs.sonatype.user") + password = project.getSensitiveProperty("libs.sonatype.password") + } + } +} + +fun configureBintrayPublication(rh: RepositoryHandler, project: Project) { + rh.maven { + val user = "kotlin" + val repo = "kotlinx" + val name = "kotlinx.coroutines" + url = URI("https://api.bintray.com/maven/$user/$repo/$name/;publish=0;override=0") + + credentials { + username = project.findProperty("bintrayUser") as? String ?: System.getenv("BINTRAY_USER") + password = project.findProperty("bintrayApiKey") as? String ?: System.getenv("BINTRAY_API_KEY") + } + } +} + +fun signPublicationIfKeyPresent(project: Project, publication: MavenPublication) { + val keyId = project.getSensitiveProperty("libs.sign.key.id") + val signingKey = project.getSensitiveProperty("libs.sign.key.private") + val signingKeyPassphrase = project.getSensitiveProperty("libs.sign.passphrase") + if (!signingKey.isNullOrBlank()) { + project.extensions.configure("signing") { + useInMemoryPgpKeys(keyId, signingKey, signingKeyPassphrase) + sign(publication) + } + } +} + +private fun Project.getSensitiveProperty(name: String): String? { + return project.findProperty(name) as? String ?: System.getenv(name) +} diff --git a/gradle/publish-bintray.gradle b/gradle/publish-bintray.gradle index b36c79763d..e785fc6473 100644 --- a/gradle/publish-bintray.gradle +++ b/gradle/publish-bintray.gradle @@ -8,6 +8,7 @@ import org.gradle.util.VersionNumber apply plugin: 'maven' apply plugin: 'maven-publish' +apply plugin: 'signing' // ------------- tasks @@ -37,16 +38,11 @@ if (!isMultiplatform && !isBom) { publishing { repositories { - maven { - def user = 'kotlin' - def repo = 'kotlinx' - def name = 'kotlinx.coroutines' - url = "https://api.bintray.com/maven/$user/$repo/$name/;publish=0" - - credentials { - username = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') - password = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') - } + def bintrayUpload = System.getenv("libs.bintray.upload") != null + if (bintrayUpload) { + PublishingKt.configureBintrayPublication(delegate, project) + } else { + PublishingKt.configureMavenPublication(delegate, project) } } @@ -65,8 +61,11 @@ publishing { } publications.all { - MavenCentralKt.configureMavenCentralMetadata(pom, project) - + PublishingKt.configureMavenCentralMetadata(pom, project) + def bintrayUpload = System.getenv("libs.bintray.upload") != null + if (!bintrayUpload) { + PublishingKt.signPublicationIfKeyPresent(project, it) + } // add empty javadocs if (!isBom && it.name != "kotlinMultiplatform") { it.artifact(javadocJar) @@ -112,12 +111,5 @@ tasks.matching { it.name == "generatePomFileForKotlinMultiplatformPublication"}. dependsOn(tasks["generatePomFileForJvmPublication"]) } -task publishDevelopSnapshot() { - def branch = System.getenv('currentBranch') - if (branch == "develop") { - dependsOn(":publish") - } -} - // Compatibility with old TeamCity configurations that perform :kotlinx-coroutines-core:bintrayUpload task bintrayUpload(dependsOn: publish)