Move to Maven Publish Gradle Plugin (#358)

* Move to Maven Publish Gradle Plugin

* Remove release scripts

* Update release docs
This commit is contained in:
David Chang 2021-12-08 09:45:33 -08:00 committed by GitHub
parent 749bc9dfcb
commit bf2adbf127
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 57 additions and 252 deletions

View file

@ -25,17 +25,23 @@ jobs:
java-version: 1.8
- name: Upload Artifacts
run: tools/release/deploy_snapshot.sh
run: ./gradlew publishAllPublicationsToMavenCentralRepository --no-daemon --no-parallel
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
ENCRYPT_KEY: ${{ secrets.ENCRYPT_KEY }}
SIGNING_ID: ${{ secrets.SIGNING_ID }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
- name: Clean up Artifacts
if: always()
run: tools/release/deploy_cleanup.sh
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }}
- name: Retrieve version
run: |
echo "VERSION_NAME=$(cat gradle.properties | grep -w "VERSION_NAME" | cut -d'=' -f2)" >> $GITHUB_ENV
- name: Publish release
run: ./gradlew closeAndReleaseRepository --no-daemon --no-parallel
if: "!endsWith(env.VERSION_NAME, '-SNAPSHOT')"
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}
test:
runs-on: ubuntu-latest
timeout-minutes: 30

View file

@ -14,6 +14,7 @@ Releasing
9. `git commit -am "Prepare next development version."`
10. Create a PR with this commit and merge it.
11. Login to Sonatype to promote the artifacts https://central.sonatype.org/pages/releasing-the-deployment.html
* This part is automated. If it fails in CI, follow the steps below.
* Click on Staging Repositories under Build Promotion
* Select all the Repositories that contain the content you want to release
* Click on Close and refresh until the Release button is active

View file

@ -17,6 +17,7 @@ buildscript {
classpath "com.diffplug.spotless:spotless-plugin-gradle:${versions.spotlessGradlePlugin}"
classpath "org.jacoco:org.jacoco.core:${versions.jacocoGradlePlugin}"
classpath "org.jetbrains.kotlinx:atomicfu-gradle-plugin:${versions.atomicFuPlugin}"
classpath "com.vanniktech:gradle-maven-publish-plugin:${versions.mavenPublishPlugin}"
}
}
@ -49,28 +50,6 @@ allprojects {
}
}
ext {
// POM file
GROUP = "com.dropbox.mobile.store"
//e2c5cbfb31bbaa9793f430a25c750195c414ac44 was the last commit compatible with kotlin 1.4
//if a release with lower compatiblity than kotlin 1.5 is needed, branch off the above commit and cherry pick any newer changes
VERSION_NAME = "4.0.4-KT15-SNAPSHOT"
POM_PACKAGING = "pom"
POM_DESCRIPTION = "Store4 is built with Kotlin Coroutines"
POM_URL = "https://github.com/dropbox/Store/"
POM_SCM_URL = "https://github.com/dropbox/Store/"
POM_SCM_CONNECTION = "scm:git:https://github.com/dropbox/Store.git"
POM_SCM_DEV_CONNECTION = "scm:git:git@github.com:dropbox/Store.git"
POM_LICENCE_NAME = "Apache License"
POM_LICENCE_URL = "http://www.apache.org/licenses/LICENSE-2.0"
POM_LICENCE_DIST = "repo"
POM_DEVELOPER_ID = "dropbox"
POM_DEVELOPER_NAME = "Dropbox"
}
subprojects {
apply plugin: 'com.diffplug.gradle.spotless'
spotless {

View file

@ -8,12 +8,13 @@ ext.versions = [
// Plugins
androidGradlePlugin : '4.1.0',
dokkaGradlePlugin : '0.10.0',
dokkaGradlePlugin : '1.6.0',
ktlintGradle : '9.1.1',
spotlessGradlePlugin : '3.26.1',
jacocoGradlePlugin : '0.8.7',
binaryCompatibilityValidator: '0.2.3',
atomicFuPlugin : '0.14.2',
mavenPublishPlugin : "0.18.0",
cache : '3.1.1',
store : '4.0.3-KT15',

6
cache/build.gradle vendored
View file

@ -17,12 +17,10 @@ dependencies {
testImplementation libraries.truth
}
group = GROUP
version = VERSION_NAME
apply from: rootProject.file("gradle/maven-push.gradle")
apply from: rootProject.file("gradle/jacoco.gradle")
apply plugin: 'com.vanniktech.maven.publish'
targetCompatibility = 1.8
sourceCompatibility = 1.8

View file

@ -7,11 +7,9 @@ buildscript {
plugins {
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.dokka'
}
group = GROUP
version = VERSION_NAME
dependencies {
implementation libraries.okio
implementation libraries.coroutinesCore
@ -24,5 +22,6 @@ dependencies {
testImplementation libraries.coroutinesTest
}
apply from: rootProject.file("gradle/maven-push.gradle")
apply from: rootProject.file("gradle/jacoco.gradle")
apply plugin: 'com.vanniktech.maven.publish'

View file

@ -5,3 +5,23 @@ org.gradle.configureondemand=true
# https://github.com/Kotlin/dokka/issues/1405
org.gradle.jvmargs=-XX:MaxMetaspaceSize=2G
// POM file
GROUP = com.dropbox.mobile.store
//e2c5cbfb31bbaa9793f430a25c750195c414ac44 was the last commit compatible with kotlin 1.4
//if a release with lower compatiblity than kotlin 1.5 is needed, branch off the above commit and cherry pick any newer changes
VERSION_NAME = 4.0.4-KT15-SNAPSHOT
POM_PACKAGING = pom
POM_DESCRIPTION = Store4 is built with Kotlin Coroutines
POM_URL = https://github.com/dropbox/Store/
POM_SCM_URL = https://github.com/dropbox/Store/
POM_SCM_CONNECTION = scm:git:https://github.com/dropbox/Store.git
POM_SCM_DEV_CONNECTION = scm:git:git@github.com:dropbox/Store.git
POM_LICENCE_NAME = Apache License
POM_LICENCE_URL = http://www.apache.org/licenses/LICENSE-2.0
POM_LICENCE_DIST = repo
POM_DEVELOPER_ID = dropbox
POM_DEVELOPER_NAME = Dropbox

View file

@ -1,169 +0,0 @@
/*
* Copyright 2013 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
apply plugin: 'maven'
apply plugin: 'signing'
version = VERSION_NAME
group = GROUP
def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
}
def getReleaseRepositoryUrl() {
return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL
: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
}
def getSnapshotRepositoryUrl() {
return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL
: "https://oss.sonatype.org/content/repositories/snapshots/"
}
def getRepositoryUsername() {
return hasProperty('SONATYPE_USERNAME') ? SONATYPE_USERNAME : ""
}
def getRepositoryPassword() {
return hasProperty('SONATYPE_PASSWORD') ? SONATYPE_PASSWORD : ""
}
afterEvaluate { project ->
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
repository(url: getReleaseRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
snapshotRepository(url: getSnapshotRepositoryUrl()) {
authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())
}
pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
}
}
}
signing {
required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
sign configurations.archives
}
install {
repositories.mavenInstaller {
pom.groupId = GROUP
pom.artifactId = POM_ARTIFACT_ID
pom.version = VERSION_NAME
pom.project {
name POM_NAME
packaging POM_PACKAGING
description POM_DESCRIPTION
url POM_URL
scm {
url POM_SCM_URL
connection POM_SCM_CONNECTION
developerConnection POM_SCM_DEV_CONNECTION
}
licenses {
license {
name POM_LICENCE_NAME
url POM_LICENCE_URL
distribution POM_LICENCE_DIST
}
}
developers {
developer {
id POM_DEVELOPER_ID
name POM_DEVELOPER_NAME
}
}
}
}
}
task sourcesJar(type: Jar, dependsOn:classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn:javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
task kotlinJavadocJar(type: Jar, dependsOn:javadoc) {
classifier = 'javadoc'
from "$buildDir/dokka"
}
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
artifacts {
if (project.getPlugins().hasPlugin('com.android.application')) {
archives androidSourcesJar
archives androidJavadocsJar
} else {
archives sourcesJar
if (project.getPlugins().hasPlugin('kotlin')) {
archives kotlinJavadocJar
} else {
archives javadocJar
}
}
}
}

View file

@ -1,7 +1,7 @@
plugins {
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.dokka'
id 'kotlinx-atomicfu'
id 'org.jetbrains.dokka'
}
dependencies {
@ -10,10 +10,10 @@ dependencies {
testImplementation libraries.kotlinTest
testImplementation libraries.kotlinTestJunit
}
group = GROUP
version = VERSION_NAME
apply from: rootProject.file("gradle/maven-push.gradle")
apply from: rootProject.file("gradle/jacoco.gradle")
apply plugin: 'com.vanniktech.maven.publish'
targetCompatibility = 1.8
sourceCompatibility = 1.8

View file

@ -16,10 +16,10 @@ dependencies {
testImplementation libraries.coroutinesTest
}
group = GROUP
version = VERSION_NAME
apply from: rootProject.file("gradle/maven-push.gradle")
apply from: rootProject.file("gradle/jacoco.gradle")
apply plugin: 'com.vanniktech.maven.publish'
targetCompatibility = 1.8
sourceCompatibility = 1.8

View file

@ -16,10 +16,10 @@ dependencies {
testImplementation libraries.coroutinesTest
}
group = GROUP
version = VERSION_NAME
apply from: rootProject.file("gradle/maven-push.gradle")
apply from: rootProject.file("gradle/jacoco.gradle")
apply plugin: 'com.vanniktech.maven.publish'
targetCompatibility = 1.8
sourceCompatibility = 1.8

View file

@ -13,9 +13,6 @@ plugins {
id 'org.jetbrains.dokka'
}
group = GROUP
version = VERSION_NAME
dependencies {
implementation libraries.cache
implementation project(path: ':multicast')
@ -28,9 +25,10 @@ dependencies {
testImplementation libraries.coroutinesTest
}
apply from: rootProject.file("gradle/maven-push.gradle")
apply from: rootProject.file("gradle/jacoco.gradle")
apply plugin: 'com.vanniktech.maven.publish'
targetCompatibility = 1.8
sourceCompatibility = 1.8
repositories {
@ -52,9 +50,3 @@ compileTestKotlin {
]
}
}
dokka {
outputFormat = 'javadoc'
outputDirectory = "$buildDir/dokkaHtml"
}

View file

@ -1,2 +0,0 @@
#!/bin/bash
rm -f tools/release/*.gpg

View file

@ -1,20 +0,0 @@
#!/bin/bash
#
# Deploy a jar, source jar, and javadoc jar to Sonatype's snapshot repo.
#
# Adapted from https://coderwall.com/p/9b_lfq and
# http://benlimmer.com/2013/12/26/automatically-publish-javadoc-to-gh-pages-with-travis-ci/
BRANCH="main"
set -e
if [ "${GITHUB_REF##*/}" != "$BRANCH" ]; then
echo "Skipping snapshot deployment: wrong branch. Expected '$BRANCH' but was '${GITHUB_REF##*/}'."
else
echo "Deploying store..."
openssl aes-256-cbc -md sha256 -d -in tools/release/secring.gpg.aes -out tools/release/secring.gpg -k "${ENCRYPT_KEY}"
# https://docs.gradle.org/current/userguide/signing_plugin.html#sec:signatory_credentials
./gradlew uploadArchives -PSONATYPE_USERNAME="${SONATYPE_USERNAME}" -PSONATYPE_PASSWORD="${SONATYPE_PASSWORD}" -Psigning.keyId="${SIGNING_ID}" -Psigning.password="${SIGNING_PASSWORD}" -Psigning.secretKeyRingFile=${PWD}/tools/release/secring.gpg
echo "Store deployed!"
fi

Binary file not shown.