Skip to content

Commit

Permalink
VIDEO-4344: Publish to MavenCentral (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
paynerc authored Mar 5, 2021
1 parent 4696b6b commit b87773a
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 28 deletions.
31 changes: 29 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ aliases:
environment:
- _JAVA_OPTIONS: "-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport"

- &signing-key
name: Install signing key
command: >
echo $SIGNING_KEY | base64 -d >> $SIGNING_SECRET_KEY_RING_FILE
- &release-filter
filters:
tags:
Expand Down Expand Up @@ -89,9 +94,19 @@ jobs:
- attach_workspace:
at: *workspace
- restore_cache: *restore_cache-gradle
- run: *signing-key
- run:
name: Publish Apkscale Pre release
command: ./gradlew -q assemble artifactoryPublish -Djfrog.username=$APKSCALE_JFROG_OSS_USERNAME -Djfrog.password=$APKSCALE_JFROG_OSS_PASSWORD -PpreRelease=true
command: |
./gradlew -q \
assemble \
artifactoryPublish \
-Dsigning.keyId=$SIGNING_KEY_ID \
-Dsigning.password=$SIGNING_PASSWORD \
-Dsigning.secretKeyRingFile=$SIGNING_SECRET_KEY_RING_FILE \
-Djfrog.username=$APKSCALE_JFROG_OSS_USERNAME \
-Djfrog.password=$APKSCALE_JFROG_OSS_PASSWORD \
-PpreRelease=true
- save_cache: *save_cache-gradle

publish-release:
Expand All @@ -102,9 +117,21 @@ jobs:
- attach_workspace:
at: *workspace
- restore_cache: *restore_cache-gradle
- run: *signing-key
- run:
name: Publish Apkscale release
command: ./gradlew -q validateReleaseTag assemble bintrayUpload -Dbintray.username=$APKSCALE_BINTRAY_USERNAME -Dbintray.password=$APKSCALE_BINTRAY_PASSWORD
command: |
./gradlew -q \
validateReleaseTag \
assemble \
publishApkscaleReleasePublicationToSonatypeRepository \
closeAndReleaseSonatypeStagingRepository \
-Dsigning.keyId=$SIGNING_KEY_ID \
-Dsigning.password=$SIGNING_PASSWORD \
-Dsigning.secretKeyRingFile=$SIGNING_SECRET_KEY_RING_FILE \
-DossrhUsername=$OSSRH_USERNAME \
-DossrhPassword=$OSSRH_PASSWORD \
-DsonatypeStagingProfileId=$SONATYPE_STAGING_PROFILE_ID
- save_cache: *save_cache-gradle

bump-version:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ gradle-app.setting
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties
.idea/

local.properties
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

### 0.1.2

Enhancements

- Now published to MavenCentral

### 0.1.1

Bug Fixes
Expand All @@ -24,7 +30,7 @@ Add the following to your project's buildscript section.
```groovy
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
}
classpath "com.twilio:apkscale:0.1.0"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ A Gradle plugin to measure the app size impact of Android libraries.

## Usage

[![Download](https://api.bintray.com/packages/twilio/releases/apkscale/images/download.svg) ](https://bintray.com/twilio/releases/apkscale/_latestVersion)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.twilio/apkscale/badge.svg) ](https://maven-badges.herokuapp.com/maven-central/com.twilio/apkscale)

Add the following to your project's buildscript section.

```groovy
buildscript {
repositories {
jcenter()
mavenCentral()
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
// Include this line if you would like to use snapshots
maven { url 'https://oss.jfrog.org/artifactory/libs-snapshot/' }
Expand Down
56 changes: 33 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ buildscript {
if(gitSha != null) return gitSha.substring(0, 7) else return ""
}

ext["signing.keyId"] = System.getProperty('signing.keyId')
ext["signing.password"] = System.getProperty('signing.password')
ext["signing.secretKeyRingFile"] = System.getProperty('signing.secretKeyRingFile')

repositories {
google()
jcenter()
Expand All @@ -24,8 +28,8 @@ plugins {
id 'java-gradle-plugin'
id 'maven-publish'
id "com.diffplug.gradle.spotless" version "4.0.1"
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
id "com.jfrog.artifactory" version "4.15.2"
id "com.jfrog.bintray" version "1.8.5"
}

apply plugin: "com.diffplug.gradle.spotless"
Expand All @@ -49,6 +53,19 @@ repositories {
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
}

nexusPublishing {
repositories {
sonatype {
username = System.getProperty('ossrhUsername')
password = System.getProperty('ossrhPassword')
stagingProfileId = System.getProperty('sonatypeStagingProfileId')
}
}

clientTimeout = Duration.ofSeconds(300)
connectTimeout = Duration.ofSeconds(60)
}

dependencies {
implementation "org.gradle:gradle-tooling-api:6.5.1"
implementation gradleApi()
Expand All @@ -64,6 +81,7 @@ dependencies {
}

apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: "com.jfrog.artifactory"

tasks.register("sourcesJar", Jar).configure {
Expand Down Expand Up @@ -108,6 +126,12 @@ publishing {
url = 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'Twilio'
name = 'Twilio'
}
}
organization {
name = 'Twilio, Inc.'
url = 'https://www.twilio.com'
Expand All @@ -117,6 +141,10 @@ publishing {
}
}

signing {
sign publishing.publications
}

artifactory {
contextUrl = 'https://oss.jfrog.org'
publish {
Expand All @@ -134,26 +162,6 @@ artifactory {
clientConfig.info.setBuildNumber(getShortCommitSha())
}

bintray {
user = System.getProperty('bintray.username')
key = System.getProperty('bintray.password')
publications = ['apkscaleRelease']
publish = true

pkg {
repo = 'releases'
name = 'apkscale'
userOrg = 'twilio'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/twilio/apkscale'
version {
name = getVersionName()
desc = getVersionName()
released = new Date()
}
}
}

/*
* Checks if release tag matches version and current commit
*/
Expand Down Expand Up @@ -182,8 +190,10 @@ task validateReleaseTag {
}

afterEvaluate {
tasks.findByName("bintrayUpload").mustRunAfter("validateReleaseTag")
tasks.findByName("bintrayUpload").dependsOn("validateReleaseTag")
tasks.findByName("publishApkscaleReleasePublicationToSonatypeRepository").mustRunAfter("validateReleaseTag")
tasks.findByName("publishApkscaleReleasePublicationToSonatypeRepository").dependsOn("validateReleaseTag")
tasks.findByName("closeAndReleaseSonatypeStagingRepository").mustRunAfter("publishApkscaleReleasePublicationToSonatypeRepository")
tasks.findByName("closeAndReleaseSonatypeStagingRepository").dependsOn("publishApkscaleReleasePublicationToSonatypeRepository")
}

task incrementVersion() {
Expand Down

0 comments on commit b87773a

Please sign in to comment.