New publication configuration (#14)

* add Dokka + align POM metadatas with sonatype requirements

* update snapshot CI

* update JNI publication

* update CI scripts

* remove maven-metadata-local.xml

* add snapshot publication with maven-publish plugin
This commit is contained in:
Romain Boisselle 2021-03-11 17:53:50 +01:00 committed by GitHub
parent 7d22d835a5
commit f493edfdfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 196 additions and 57 deletions

View File

@ -89,24 +89,38 @@ jobs:
BINTRAY_USER: ${{ secrets.bintray_user }} BINTRAY_USER: ${{ secrets.bintray_user }}
BINTRAY_APIKEY: ${{ secrets.bintray_apikey }} BINTRAY_APIKEY: ${{ secrets.bintray_apikey }}
shell: bash shell: bash
run: ./gradlew publishLinuxPublicationToBintrayRepository :jni:jvm:linux:publishJvmPublicationToBintrayRepository # ./gradlew publishLinuxPublicationToBintrayRepository :jni:jvm:linux:publishJvmPublicationToBintrayRepository
run: ./gradlew publishLinuxPublicationToMavenLocal :jni:jvm:linux:publishJvmPublicationToMavenLocal
- name: Publish Windows - name: Publish Windows
if: matrix.os == 'windows-latest' if: matrix.os == 'windows-latest'
env: env:
BINTRAY_USER: ${{ secrets.bintray_user }} BINTRAY_USER: ${{ secrets.bintray_user }}
BINTRAY_APIKEY: ${{ secrets.bintray_apikey }} BINTRAY_APIKEY: ${{ secrets.bintray_apikey }}
shell: bash shell: bash
run: ./gradlew :jni:jvm:mingw:publishJvmPublicationToBintrayRepository # ./gradlew :jni:jvm:mingw:publishJvmPublicationToBintrayRepository
run: ./gradlew :jni:jvm:mingw:publishToMavenLocal
- name: Publish MacOS - name: Publish MacOS
if: matrix.os == 'macOS-latest' if: matrix.os == 'macOS-latest'
env: env:
BINTRAY_USER: ${{ secrets.bintray_user }} BINTRAY_USER: ${{ secrets.bintray_user }}
BINTRAY_APIKEY: ${{ secrets.bintray_apikey }} BINTRAY_APIKEY: ${{ secrets.bintray_apikey }}
shell: bash shell: bash
run: ./gradlew publish # ./gradlew publish
- name: Discard run: ./gradlew publishToMavenLocal
if: ${{ failure() || cancelled() }} - name: Copy artifact files
env: run: |
BINTRAY_USER: ${{ secrets.bintray_user }} mkdir -p maven-local/release
BINTRAY_APIKEY: ${{ secrets.bintray_apikey }} cp -r ~/.m2/repository/* maven-local/release
run: ./gradlew postBintrayDiscard - name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: release
path: |
maven-local
!maven-local/**/maven-metadata-local.xml
# - name: Discard
# if: ${{ failure() || cancelled() }}
# env:
# BINTRAY_USER: ${{ secrets.bintray_user }}
# BINTRAY_APIKEY: ${{ secrets.bintray_apikey }}
# run: ./gradlew postBintrayDiscard

View File

@ -3,7 +3,7 @@ name: Publish snapshot
on: on:
push: push:
branches: branches:
- 'snapshot/*' - 'master'
paths-ignore: paths-ignore:
- '**.md' - '**.md'
- '**.adoc' - '**.adoc'
@ -97,49 +97,64 @@ jobs:
BINTRAY_USER: ${{ secrets.bintray_user }} BINTRAY_USER: ${{ secrets.bintray_user }}
BINTRAY_APIKEY: ${{ secrets.bintray_apikey }} BINTRAY_APIKEY: ${{ secrets.bintray_apikey }}
shell: bash shell: bash
run: ./gradlew publishLinuxPublicationToBintrayRepository :jni:jvm:linux:publishJvmPublicationToBintrayRepository -PsnapshotNumber=${{ github.run_number }} -PgitRef=${{ github.ref }} # ./gradlew publishLinuxPublicationToBintrayRepository :jni:jvm:linux:publishJvmPublicationToBintrayRepository -PsnapshotNumber=${{ github.run_number }} -PgitRef=${{ github.ref }}
run: ./gradlew publishLinuxPublicationToMavenLocal :jni:jvm:linux:publishJvmPublicationToMavenLocal -PsnapshotNumber=${{ github.run_number }} -PgitRef=${{ github.ref }}
- name: Publish Windows - name: Publish Windows
if: matrix.os == 'windows-latest' if: matrix.os == 'windows-latest'
env: env:
BINTRAY_USER: ${{ secrets.bintray_user }} BINTRAY_USER: ${{ secrets.bintray_user }}
BINTRAY_APIKEY: ${{ secrets.bintray_apikey }} BINTRAY_APIKEY: ${{ secrets.bintray_apikey }}
shell: bash shell: bash
run: ./gradlew :jni:jvm:mingw:publishJvmPublicationToBintrayRepository -PsnapshotNumber=${{ github.run_number }} -PgitRef=${{ github.ref }} # ./gradlew :jni:jvm:mingw:publishJvmPublicationToBintrayRepository -PsnapshotNumber=${{ github.run_number }} -PgitRef=${{ github.ref }}
run: ./gradlew :jni:jvm:mingw:publishToMavenLocal -PsnapshotNumber=${{ github.run_number }} -PgitRef=${{ github.ref }}
- name: Publish MacOS - name: Publish MacOS
if: matrix.os == 'macOS-latest' if: matrix.os == 'macOS-latest'
env: env:
BINTRAY_USER: ${{ secrets.bintray_user }} BINTRAY_USER: ${{ secrets.bintray_user }}
BINTRAY_APIKEY: ${{ secrets.bintray_apikey }} BINTRAY_APIKEY: ${{ secrets.bintray_apikey }}
shell: bash shell: bash
run: ./gradlew publish -PsnapshotNumber=${{ github.run_number }} -PgitRef=${{ github.ref }} # ./gradlew publish -PsnapshotNumber=${{ github.run_number }} -PgitRef=${{ github.ref }}
- name: Discard run: ./gradlew publishToMavenLocal -PsnapshotNumber=${{ github.run_number }} -PgitRef=${{ github.ref }}
if: ${{ failure() || cancelled() }} - name: Copy artifact files
env: shell: bash
BINTRAY_USER: ${{ secrets.bintray_user }} run: |
BINTRAY_APIKEY: ${{ secrets.bintray_apikey }} mkdir -p maven-local/snapshot
run: ./gradlew postBintrayDiscard -PsnapshotNumber=${{ github.run_number }} -PgitRef=${{ github.ref }} cp -r ~/.m2/repository/* maven-local/snapshot
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: snapshot
path: |
maven-local
!maven-local/**/maven-metadata-local.xml
# - name: Discard
# if: ${{ failure() || cancelled() }}
# env:
# BINTRAY_USER: ${{ secrets.bintray_user }}
# BINTRAY_APIKEY: ${{ secrets.bintray_apikey }}
# run: ./gradlew postBintrayDiscard -PsnapshotNumber=${{ github.run_number }} -PgitRef=${{ github.ref }}
publish: # publish:
name: Publish # name: Publish
needs: upload # needs: upload
runs-on: ubuntu-latest # runs-on: ubuntu-latest
steps: # steps:
- name: Check out # - name: Check out
uses: actions/checkout@v2 # uses: actions/checkout@v2
with: # with:
submodules: 'true' # submodules: 'true'
- name: Cached Gradle # - name: Cached Gradle
uses: actions/cache@v2 # uses: actions/cache@v2
with: # with:
path: ~/.gradle # path: ~/.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} # key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle- # restore-keys: ${{ runner.os }}-gradle-
- name: Set up JDK 11 # - name: Set up JDK 11
uses: actions/setup-java@v1 # uses: actions/setup-java@v1
with: # with:
java-version: 11 # java-version: 11
- name: Publish # - name: Publish
env: # env:
BINTRAY_USER: ${{ secrets.bintray_user }} # BINTRAY_USER: ${{ secrets.bintray_user }}
BINTRAY_APIKEY: ${{ secrets.bintray_apikey }} # BINTRAY_APIKEY: ${{ secrets.bintray_apikey }}
run: ./gradlew postBintrayPublish -PsnapshotNumber=${{ github.run_number }} -PgitRef=${{ github.ref }} # run: ./gradlew postBintrayPublish -PsnapshotNumber=${{ github.run_number }} -PgitRef=${{ github.ref }}

View File

@ -10,7 +10,7 @@ on:
- '!.github/workflows/test.yml' - '!.github/workflows/test.yml'
push: push:
branches: branches:
- 'master' - '!master'
paths-ignore: paths-ignore:
- '**.md' - '**.md'
- '**.adoc' - '**.adoc'

View File

@ -6,9 +6,11 @@ import org.apache.http.impl.auth.BasicScheme
import org.apache.http.auth.UsernamePasswordCredentials import org.apache.http.auth.UsernamePasswordCredentials
import org.gradle.internal.os.OperatingSystem import org.gradle.internal.os.OperatingSystem
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.dokka.Platform
plugins { plugins {
kotlin("multiplatform") version "1.4.31" kotlin("multiplatform") version "1.4.31"
id("org.jetbrains.dokka") version "1.4.20"
`maven-publish` `maven-publish`
} }
@ -16,20 +18,23 @@ buildscript {
repositories { repositories {
google() google()
mavenCentral() mavenCentral()
jcenter()
} }
dependencies { dependencies {
classpath("com.android.tools.build:gradle:4.0.2") classpath("com.android.tools.build:gradle:4.0.2")
classpath("org.jetbrains.dokka:dokka-gradle-plugin:1.4.20")
} }
} }
allprojects { allprojects {
group = "fr.acinq.secp256k1" group = "fr.acinq.secp256k1"
version = "0.5.0" version = "0.5.1-SNAPSHOT"
repositories { repositories {
jcenter() jcenter()
google() google()
mavenCentral()
} }
} }
@ -107,22 +112,30 @@ allprojects {
} }
} }
val snapshotNumber: String? by project // Publication
val gitRef: String? by project val bintrayRepo = if (project.version.toString().contains("SNAPSHOT")) "snapshots" else "libs"
val eapBranch = gitRef?.split("/")?.last() ?: "dev"
val bintrayVersion = if (snapshotNumber != null) "${project.version}-$eapBranch-$snapshotNumber" else project.version.toString()
val bintrayRepo = if (snapshotNumber != null) "snapshots" else "libs"
val bintrayUsername: String? = (properties["bintrayUsername"] as String?) ?: System.getenv("BINTRAY_USER") val bintrayUsername: String? = (properties["bintrayUsername"] as String?) ?: System.getenv("BINTRAY_USER")
val bintrayApiKey: String? = (properties["bintrayApiKey"] as String?) ?: System.getenv("BINTRAY_APIKEY") val bintrayApiKey: String? = (properties["bintrayApiKey"] as String?) ?: System.getenv("BINTRAY_APIKEY")
val hasBintray = bintrayUsername != null && bintrayApiKey != null val hasBintray = bintrayUsername != null && bintrayApiKey != null
if (!hasBintray) logger.warn("Skipping bintray configuration as bintrayUsername or bintrayApiKey is not defined") if (!hasBintray) logger.warn("Skipping bintray configuration as bintrayUsername or bintrayApiKey is not defined")
val sonatypeUsername: String? = (properties["sonatypeUsername"] as String?) ?: System.getenv("SONATYPE_USERNAME")
val sonatypePassword: String? = (properties["sonatypePassword"] as String?) ?: System.getenv("SONATYPE_PASSWORD")
val hasSonatype = sonatypeUsername != null && sonatypePassword != null
if (!hasSonatype) logger.warn("Skipping sonatype snapshot configuration as sonatypeUsername or sonatypePassword is not defined")
allprojects { allprojects {
val javadocJar = tasks.create<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
// Publication
plugins.withId("maven-publish") { plugins.withId("maven-publish") {
publishing { publishing {
if (hasBintray) { repositories {
repositories { if (hasBintray) {
maven { maven {
name = "bintray" name = "bintray"
setUrl("https://api.bintray.com/maven/acinq/$bintrayRepo/${rootProject.name}/;publish=0") setUrl("https://api.bintray.com/maven/acinq/$bintrayRepo/${rootProject.name}/;publish=0")
@ -132,16 +145,31 @@ allprojects {
} }
} }
} }
if (hasSonatype) {
maven {
name = "snapshot"
setUrl("https://oss.sonatype.org/content/repositories/snapshots")
credentials {
username = sonatypeUsername
password = sonatypePassword
}
}
}
} }
publications.withType<MavenPublication>().configureEach { publications.withType<MavenPublication>().configureEach {
version = bintrayVersion version = project.version.toString()
artifact(javadocJar)
pom { pom {
name.set("secp256k1 for Kotlin/Multiplatform")
description.set("Bitcoin's secp256k1 library ported to Kotlin/Multiplatform for JVM, Android, iOS & Linux") description.set("Bitcoin's secp256k1 library ported to Kotlin/Multiplatform for JVM, Android, iOS & Linux")
url.set("https://github.com/ACINQ/secp256k1-kmp") url.set("https://github.com/ACINQ/secp256k1-kmp")
licenses { licenses {
name.set("Apache License v2.0") license {
url.set("https://www.apache.org/licenses/LICENSE-2.0") name.set("Apache License v2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0")
}
} }
issueManagement { issueManagement {
system.set("Github") system.set("Github")
@ -149,18 +177,58 @@ allprojects {
} }
scm { scm {
connection.set("https://github.com/ACINQ/secp256k1-kmp.git") connection.set("https://github.com/ACINQ/secp256k1-kmp.git")
url.set("https://github.com/ACINQ/secp256k1-kmp")
}
developers {
developer {
name.set("ACINQ")
email.set("hello@acinq.co")
}
} }
} }
} }
} }
} }
if (project.name !in listOf("native", "tests")) {
afterEvaluate {
val dokkaOutputDir = buildDir.resolve("dokka")
tasks.dokkaHtml {
outputDirectory.set(file(dokkaOutputDir))
dokkaSourceSets {
configureEach {
val platformName = when (platform.get()) {
Platform.jvm -> "jvm"
Platform.js -> "js"
Platform.native -> "native"
Platform.common -> "common"
}
displayName.set(platformName)
perPackageOption {
matchingRegex.set(".*\\.internal.*") // will match all .internal packages and sub-packages
suppress.set(true)
}
}
}
}
val deleteDokkaOutputDir by tasks.register<Delete>("deleteDokkaOutputDirectory") {
delete(dokkaOutputDir)
}
javadocJar.dependsOn(deleteDokkaOutputDir, tasks.dokkaHtml)
javadocJar.from(dokkaOutputDir)
}
}
} }
if (hasBintray) { if (hasBintray) {
val postBintrayPublish by tasks.creating { val postBintrayPublish by tasks.creating {
doLast { doLast {
HttpClients.createDefault().use { client -> HttpClients.createDefault().use { client ->
val post = HttpPost("https://api.bintray.com/content/acinq/$bintrayRepo/${rootProject.name}/$bintrayVersion/publish").apply { val post = HttpPost("https://api.bintray.com/content/acinq/$bintrayRepo/${rootProject.name}/${project.version.toString()}/publish").apply {
entity = StringEntity("{}", ContentType.APPLICATION_JSON) entity = StringEntity("{}", ContentType.APPLICATION_JSON)
addHeader(BasicScheme().authenticate(UsernamePasswordCredentials(bintrayUsername, bintrayApiKey), this, null)) addHeader(BasicScheme().authenticate(UsernamePasswordCredentials(bintrayUsername, bintrayApiKey), this, null))
} }
@ -172,7 +240,7 @@ if (hasBintray) {
val postBintrayDiscard by tasks.creating { val postBintrayDiscard by tasks.creating {
doLast { doLast {
HttpClients.createDefault().use { client -> HttpClients.createDefault().use { client ->
val post = HttpPost("https://api.bintray.com/content/acinq/$bintrayRepo/${rootProject.name}/$bintrayVersion/publish").apply { val post = HttpPost("https://api.bintray.com/content/acinq/$bintrayRepo/${rootProject.name}/${project.version.toString()}/publish").apply {
entity = StringEntity("{ \"discard\": true }", ContentType.APPLICATION_JSON) entity = StringEntity("{ \"discard\": true }", ContentType.APPLICATION_JSON)
addHeader(BasicScheme().authenticate(UsernamePasswordCredentials(bintrayUsername, bintrayApiKey), this, null)) addHeader(BasicScheme().authenticate(UsernamePasswordCredentials(bintrayUsername, bintrayApiKey), this, null))
} }

View File

@ -1,6 +1,9 @@
import org.jetbrains.dokka.Platform
plugins { plugins {
id("com.android.library") id("com.android.library")
kotlin("android") kotlin("android")
id("org.jetbrains.dokka")
`maven-publish` `maven-publish`
} }
@ -53,6 +56,11 @@ afterEvaluate {
create<MavenPublication>("android") { create<MavenPublication>("android") {
artifactId = "secp256k1-kmp-jni-android" artifactId = "secp256k1-kmp-jni-android"
from(components["release"]) from(components["release"])
val sourcesJar = task<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(android.sourceSets["main"].java.srcDirs)
}
artifact(sourcesJar)
} }
} }
} }

View File

@ -1,5 +1,8 @@
import org.jetbrains.dokka.Platform
plugins { plugins {
kotlin("jvm") kotlin("jvm")
id("org.jetbrains.dokka")
`maven-publish` `maven-publish`
} }
@ -36,6 +39,11 @@ publishing {
create<MavenPublication>("jvm") { create<MavenPublication>("jvm") {
artifactId = "secp256k1-kmp-jni-common" artifactId = "secp256k1-kmp-jni-common"
from(components["java"]) from(components["java"])
val sourcesJar = task<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}
artifact(sourcesJar)
} }
} }
} }

View File

@ -1,5 +1,6 @@
plugins { plugins {
`java-library` `java-library`
id("org.jetbrains.dokka")
`maven-publish` `maven-publish`
} }
@ -14,6 +15,10 @@ publishing {
create<MavenPublication>("jvm") { create<MavenPublication>("jvm") {
artifactId = "secp256k1-kmp-jni-jvm" artifactId = "secp256k1-kmp-jni-jvm"
from(components["java"]) from(components["java"])
val sourcesJar = task<Jar>("sourcesJar") {
archiveClassifier.set("sources")
}
artifact(sourcesJar)
} }
} }
} }

View File

@ -1,5 +1,6 @@
plugins { plugins {
kotlin("jvm") kotlin("jvm")
id("org.jetbrains.dokka")
`maven-publish` `maven-publish`
} }
@ -35,6 +36,10 @@ publishing {
create<MavenPublication>("jvm") { create<MavenPublication>("jvm") {
artifactId = "secp256k1-kmp-jni-jvm-extract" artifactId = "secp256k1-kmp-jni-jvm-extract"
from(components["java"]) from(components["java"])
val sourcesJar = task<Jar>("sourcesJar") {
archiveClassifier.set("sources")
}
artifact(sourcesJar)
} }
} }
} }

View File

@ -1,5 +1,7 @@
plugins { plugins {
kotlin("jvm") kotlin("jvm")
`java-library`
id("org.jetbrains.dokka")
`maven-publish` `maven-publish`
} }
@ -25,6 +27,10 @@ publishing {
val pub = create<MavenPublication>("jvm") { val pub = create<MavenPublication>("jvm") {
artifactId = "secp256k1-kmp-jni-jvm-darwin" artifactId = "secp256k1-kmp-jni-jvm-darwin"
from(components["java"]) from(components["java"])
val sourcesJar = task<Jar>("sourcesJar") {
archiveClassifier.set("sources")
}
artifact(sourcesJar)
} }
if (!org.gradle.internal.os.OperatingSystem.current().isMacOsX) { if (!org.gradle.internal.os.OperatingSystem.current().isMacOsX) {
tasks.withType<AbstractPublishToMaven>().all { onlyIf { publication != pub } } tasks.withType<AbstractPublishToMaven>().all { onlyIf { publication != pub } }

View File

@ -1,5 +1,6 @@
plugins { plugins {
kotlin("jvm") kotlin("jvm")
id("org.jetbrains.dokka")
`maven-publish` `maven-publish`
} }
@ -25,6 +26,10 @@ publishing {
val pub = create<MavenPublication>("jvm") { val pub = create<MavenPublication>("jvm") {
artifactId = "secp256k1-kmp-jni-jvm-linux" artifactId = "secp256k1-kmp-jni-jvm-linux"
from(components["java"]) from(components["java"])
val sourcesJar = task<Jar>("sourcesJar") {
archiveClassifier.set("sources")
}
artifact(sourcesJar)
} }
if (!org.gradle.internal.os.OperatingSystem.current().isLinux) { if (!org.gradle.internal.os.OperatingSystem.current().isLinux) {
tasks.withType<AbstractPublishToMaven>().all { onlyIf { publication != pub } } tasks.withType<AbstractPublishToMaven>().all { onlyIf { publication != pub } }

View File

@ -1,5 +1,6 @@
plugins { plugins {
kotlin("jvm") kotlin("jvm")
id("org.jetbrains.dokka")
`maven-publish` `maven-publish`
} }
@ -25,6 +26,10 @@ publishing {
val pub = create<MavenPublication>("jvm") { val pub = create<MavenPublication>("jvm") {
artifactId = "secp256k1-kmp-jni-jvm-mingw" artifactId = "secp256k1-kmp-jni-jvm-mingw"
from(components["java"]) from(components["java"])
val sourcesJar = task<Jar>("sourcesJar") {
archiveClassifier.set("sources")
}
artifact(sourcesJar)
} }
if (!org.gradle.internal.os.OperatingSystem.current().isWindows) { if (!org.gradle.internal.os.OperatingSystem.current().isWindows) {
tasks.withType<AbstractPublishToMaven>().all { onlyIf { publication != pub } } tasks.withType<AbstractPublishToMaven>().all { onlyIf { publication != pub } }