From 13212fd84879e8cf8af79ae44a6795f519d1c311 Mon Sep 17 00:00:00 2001 From: Langston Smith Date: Thu, 4 Jul 2019 01:24:43 -0700 Subject: [PATCH] Moving release process to Bintray (#72) --- Makefile | 9 +-- README.md | 4 +- build.gradle | 8 +- circle.yml | 30 ++++--- gradle/artifact-settings.gradle | 20 +++++ gradle/dependencies.gradle | 14 +++- gradle/gradle-bintray.gradle | 91 +++++++++++++++++++++ gradle/javadoc.gradle | 19 +++++ gradle/mvn-push-android.gradle | 138 -------------------------------- library/build.gradle | 2 +- library/javadoc.gradle | 17 ---- 11 files changed, 172 insertions(+), 180 deletions(-) create mode 100644 gradle/artifact-settings.gradle create mode 100644 gradle/gradle-bintray.gradle create mode 100644 gradle/javadoc.gradle delete mode 100644 gradle/mvn-push-android.gradle delete mode 100644 library/javadoc.gradle diff --git a/Makefile b/Makefile index 98a4ef0..867c3f4 100644 --- a/Makefile +++ b/Makefile @@ -11,9 +11,8 @@ test: release: ./gradlew :library:assembleRelease -publish: - export IS_LOCAL_DEVELOPMENT=false; ./gradlew :library:uploadArchives +publish-stable: + ./gradlew :library:bintrayUpload -publish-local: - # This publishes to ~/.m2/repository/com/mapbox/mapboxsdk - export IS_LOCAL_DEVELOPMENT=true; ./gradlew :library:uploadArchives \ No newline at end of file +publish-snapshot-to-artifactory: + ./gradlew :library:artifactoryPublish diff --git a/README.md b/README.md index 7d2a73e..bc1c317 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,8 @@ The library is published to Maven Central and SNAPSHOTS are available whenever n ```java // In the root build.gradle file repositories { - mavenCentral() - maven { url "http://oss.sonatype.org/content/repositories/snapshots/" } + jcenter() + maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local/' } } ``` ```java diff --git a/build.gradle b/build.gradle index 0633ab7..28acdc4 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,9 @@ buildscript { } dependencies { classpath pluginDependencies.gradle - + classpath pluginDependencies.bintrayPlugin + classpath pluginDependencies.androidPublishPlugin + classpath pluginDependencies.artifactory // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -18,6 +20,7 @@ allprojects { repositories { google() jcenter() + maven { url 'https://mapbox.bintray.com/mapbox' } } } @@ -25,11 +28,10 @@ subprojects { subproject -> apply plugin: 'idea' if (subproject.name == "library") { - apply from: "../gradle/mvn-push-android.gradle" apply from: "../gradle/checkstyle.gradle" } } task clean(type: Delete) { delete rootProject.buildDir -} +} \ No newline at end of file diff --git a/circle.yml b/circle.yml index da2ab7c..7aaee70 100644 --- a/circle.yml +++ b/circle.yml @@ -62,23 +62,33 @@ jobs: steps: - checkout - run: - name: Generate Maven credentials + name: Generate Bintray credentials shell: /bin/bash -euo pipefail command: | - aws s3 cp s3://mapbox/android/signing-credentials/secring.gpg secring.gpg - echo "NEXUS_USERNAME=$PUBLISH_NEXUS_USERNAME - NEXUS_PASSWORD=$PUBLISH_NEXUS_PASSWORD - signing.keyId=$SIGNING_KEYID - signing.password=$SIGNING_PASSWORD - signing.secretKeyRingFile=../secring.gpg" >> gradle.properties + if [ -n "${BINTRAY_USER}" ]; then + echo "BINTRAY_USER=$BINTRAY_USER + BINTRAY_API_KEY=$BINTRAY_API_KEY + GPG_PASSPHRASE=$GPG_PASSPHRASE" + fi + - run: + name: Update version name + command: | + if [[ $CIRCLE_TAG == v* ]]; then + sed -i -e "s/^VERSION_NAME=.*/VERSION_NAME=${CIRCLE_TAG:9}/" library/gradle.properties + fi - run: name: Build libraries command: make release - deploy: - name: Publish to Maven Central + name: Publish to Bintray command: | - if [ "${CIRCLE_BRANCH}" == "master" ]; then - make publish ; + if [[ $CIRCLE_BRANCH == master ]] || [[ $CIRCLE_TAG == v* ]]; then + version=$(cat library/gradle.properties | grep "VERSION_NAME") + if [[ $version != *"SNAPSHOT"* ]]; then + make publish-stable + else + make publish-snapshot-to-artifactory + fi fi - store_artifacts: path: app/build/reports diff --git a/gradle/artifact-settings.gradle b/gradle/artifact-settings.gradle new file mode 100644 index 0000000..df70eb0 --- /dev/null +++ b/gradle/artifact-settings.gradle @@ -0,0 +1,20 @@ +ext { + mapboxArtifactGroupId = 'com.mapbox.mapboxsdk' + mapboxArtifactId = 'mapbox-android-gestures' + mapboxArtifactTitle = 'Mapbox Android Gestures Library' + mapboxArtifactDescription = 'Mapbox Android Gestures Library' + mapboxDeveloperName = 'Mapbox' + mapboxDeveloperId = 'mapbox' + mapboxArtifactUrl = 'https://github.com/mapbox/mapbox-gestures-android' + mapboxArtifactVcsUrl = 'https://github.com/mapbox/mapbox-gestures-android.git' + mapboxArtifactScmUrl = 'scm:git@github.com/mapbox/mapbox-gestures-android.git' + mapboxArtifactLicenseName = 'BSD' + mapboxArtifactLicenseUrl = 'https://opensource.org/licenses/BSD-2-Clause' + versionName = project.hasProperty('VERSION_NAME') ? project.property('VERSION_NAME') : System.getenv('VERSION_NAME') + + mapboxBintrayUserOrg = 'mapbox' + mapboxBintrayRepoName = 'mapbox' + mapboxBintrayUser = project.hasProperty('BINTRAY_USER') ? project.property('BINTRAY_USER') : System.getenv('BINTRAY_USER') + mapboxBintrayApiKey = project.hasProperty('BINTRAY_API_KEY') ? project.property('BINTRAY_API_KEY') : System.getenv('BINTRAY_API_KEY') + mapboxGpgPassphrase = project.hasProperty('GPG_PASSPHRASE') ? project.property('GPG_PASSPHRASE') : System.getenv('GPG_PASSPHRASE') +} \ No newline at end of file diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 4e16ce0..fdd282e 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -17,8 +17,11 @@ ext { ] pluginVersion = [ - checkstyle: '8.4', - gradle : '3.3.0' + checkstyle : '8.4', + gradle : '3.3.0', + bintray : '1.8.4', + androidPublish : '3.6.2', + artifactory : '4.9.3', ] dependenciesList = [ @@ -47,7 +50,10 @@ ext { ] pluginDependencies = [ - gradle : "com.android.tools.build:gradle:${pluginVersion.gradle}", - checkstyle: "com.puppycrawl.tools:checkstyle:${pluginVersion.checkstyle}" + gradle : "com.android.tools.build:gradle:${pluginVersion.gradle}", + checkstyle : "com.puppycrawl.tools:checkstyle:${pluginVersion.checkstyle}", + bintrayPlugin : "com.jfrog.bintray.gradle:gradle-bintray-plugin:${pluginVersion.bintray}", + androidPublishPlugin : "digital.wup:android-maven-publish:${pluginVersion.androidPublish}", + artifactory : "org.jfrog.buildinfo:build-info-extractor-gradle:${pluginVersion.artifactory}" ] } \ No newline at end of file diff --git a/gradle/gradle-bintray.gradle b/gradle/gradle-bintray.gradle new file mode 100644 index 0000000..c5c50a2 --- /dev/null +++ b/gradle/gradle-bintray.gradle @@ -0,0 +1,91 @@ +apply plugin: 'digital.wup.android-maven-publish' +apply plugin: 'maven-publish' +apply plugin: 'com.jfrog.bintray' +apply plugin: 'com.jfrog.artifactory' +apply from: file('../gradle/artifact-settings.gradle') + +publishing { + publications { + MapboxGesturesPublication(MavenPublication) { + from components.android + groupId project.ext.mapboxArtifactGroupId + artifactId project.ext.mapboxArtifactId + version project.ext.versionName + + afterEvaluate { + artifact("$buildDir/outputs/aar/${project.name}-release.aar") + artifact(androidSourcesJar) + artifact(androidJavadocsJar) + } + + pom.withXml { + final mainNode = asNode() + mainNode.appendNode('name', project.ext.mapboxArtifactTitle) + mainNode.appendNode('description', project.ext.mapboxArtifactTitle) + mainNode.appendNode('url', project.ext.mapboxArtifactUrl) + + final licenseNode = mainNode.appendNode('licenses').appendNode('license') + licenseNode.appendNode('name', project.ext.mapboxArtifactLicenseName) + licenseNode.appendNode('url', project.ext.mapboxArtifactLicenseUrl) + licenseNode.appendNode('distribution', "repo") + + final developerNode = mainNode.appendNode('developers').appendNode('developer') + developerNode.appendNode('id', project.ext.mapboxDeveloperId) + developerNode.appendNode('name', project.ext.mapboxDeveloperName) + + final scmNode = mainNode.appendNode("scm") + scmNode.appendNode("connection", project.ext.mapboxArtifactScmUrl) + scmNode.appendNode("developerConnection", project.ext.mapboxArtifactScmUrl) + scmNode.appendNode("url", project.ext.mapboxArtifactUrl) + } + + } + } +} + +bintray { + user = mapboxBintrayUser + key = mapboxBintrayApiKey + publications = ['MapboxGesturesPublication'] + pkg { + repo = project.ext.mapboxBintrayRepoName + name = project.ext.mapboxArtifactId + userOrg = project.ext.mapboxBintrayUserOrg + licenses = [project.ext.mapboxArtifactLicenseName] + vcsUrl = project.ext.mapboxArtifactVcsUrl + publish = false + version { + name = project.ext.versionName + desc = project.ext.mapboxArtifactDescription + released = new Date() + gpg { + sign = true + passphrase = mapboxGpgPassphrase + } + mavenCentralSync { + sync = false + } + } + } +} + +artifactory { + contextUrl = 'http://oss.jfrog.org' + publish { + repository { + repoKey = 'oss-snapshot-local' + username = mapboxBintrayUser + password = mapboxBintrayApiKey + } + defaults { + publications('MapboxGesturesPublication') + } + } +} + + +tasks.withType(Javadoc) { + options.addStringOption('encoding', 'UTF-8') + options.addStringOption('docencoding', 'UTF-8') + options.addStringOption('charset', 'UTF-8') +} diff --git a/gradle/javadoc.gradle b/gradle/javadoc.gradle new file mode 100644 index 0000000..2776cf7 --- /dev/null +++ b/gradle/javadoc.gradle @@ -0,0 +1,19 @@ +apply from: "${rootDir}/gradle/dependencies.gradle" + +android.libraryVariants.all { variant -> + def name = variant.name + task "javadoc$name"(type: Javadoc) { + description = "Generates javadoc for build $name" + failOnError = false + destinationDir = new File(destinationDir, variant.baseName) + source = variant.sourceSets.collect { it.java.sourceFiles }.inject { m, i -> m + i } + classpath = files(android.bootClasspath) + options.windowTitle("$POM_NAME $VERSION_NAME Reference") + options.docTitle("$POM_NAME $VERSION_NAME") + options.header("$POM_NAME $VERSION_NAME Reference") + options.bottom("© 2015–2019 Mapbox. All rights reserved.") + options.links("http://docs.oracle.com/javase/7/docs/api/") + options.linksOffline("http://d.android.com/reference/", "$System.env.ANDROID_HOME/docs/reference") + exclude '**/R.java', '**/BuildConfig.java', '**/*.kt' + } +} \ No newline at end of file diff --git a/gradle/mvn-push-android.gradle b/gradle/mvn-push-android.gradle deleted file mode 100644 index e71327a..0000000 --- a/gradle/mvn-push-android.gradle +++ /dev/null @@ -1,138 +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' - -def isReleaseBuild() { - return VERSION_NAME.contains("SNAPSHOT") == false -} - -def isLocalBuild() { - if (System.getenv('IS_LOCAL_DEVELOPMENT') != null) { - return System.getenv('IS_LOCAL_DEVELOPMENT').toBoolean() - } - return true -} - -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 obtainMavenLocalUrl() { - return getRepositories().mavenLocal().getUrl() -} - -def getRepositoryUsername() { - return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "" -} - -def getRepositoryPassword() { - return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "" -} - -afterEvaluate { project -> - uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - pom.groupId = GROUP - pom.artifactId = POM_ARTIFACT_ID - pom.version = VERSION_NAME - - if (isLocalBuild()) { - repository(url: obtainMavenLocalUrl()) - } else { - 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 - } - - task androidJavadocs(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - } - - task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { - classifier = 'javadoc' - from androidJavadocs.destinationDir - } - - task androidSourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.sourceFiles - } - - artifacts { - archives androidSourcesJar - archives androidJavadocsJar - } -} - -// See: https://github.com/chrisbanes/gradle-mvn-push/issues/43#issuecomment-84140513 -afterEvaluate { project -> - android.libraryVariants.all { variant -> - tasks.androidJavadocs.doFirst { - classpath += files(variant.javaCompile.classpath.files) - } - } -} \ No newline at end of file diff --git a/library/build.gradle b/library/build.gradle index a337ed1..64ed0dc 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -43,4 +43,4 @@ dependencies { androidTestImplementation dependenciesList.testEspressoCore } -apply from: 'javadoc.gradle' \ No newline at end of file +apply from: "${rootDir}/gradle/gradle-bintray.gradle" diff --git a/library/javadoc.gradle b/library/javadoc.gradle deleted file mode 100644 index 9d0a5ca..0000000 --- a/library/javadoc.gradle +++ /dev/null @@ -1,17 +0,0 @@ -android.libraryVariants.all { variant -> - def name = variant.name - task "javadoc$name"(type: Javadoc) { - description = "Generates javadoc for build $name" - failOnError = false - destinationDir = new File(destinationDir, variant.baseName) - source = variant.sourceSets.collect { it.java.sourceFiles }.inject { m, i -> m + i } - options.windowTitle("Mapbox Android Gestures $VERSION_NAME Reference") - options.docTitle("Mapbox Android Gestures $VERSION_NAME") - options.tags("attr") - options.header("Mapbox Android Gestures $VERSION_NAME Reference") - options.bottom("© 2018 Mapbox. All rights reserved.") - options.links("http://docs.oracle.com/javase/7/docs/api/") - options.linksOffline("http://d.android.com/reference/", "$System.env.ANDROID_HOME/docs/reference") - exclude '**/R.java', '**/BuildConfig.java' - } -} \ No newline at end of file