-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup new publishing scripts for MavenCentral (#323)
* Setup new publishing scripts for MavenCentral * removed unneeded code
- Loading branch information
1 parent
f753d23
commit 3638a48
Showing
7 changed files
with
174 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Publish | ||
|
||
on: | ||
release: | ||
# We'll run this workflow when a new GitHub release is created | ||
types: [released] | ||
|
||
jobs: | ||
publish: | ||
name: Release build and publish | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
|
||
# Base64 decodes and pipes the GPG key content into the secret file | ||
- name: Prepare environment | ||
env: | ||
GPG_KEY_CONTENTS: ${{ secrets.GPG_KEY_CONTENTS }} | ||
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }} | ||
run: | | ||
git fetch --unshallow | ||
sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_SECRET_KEY_RING_FILE'" | ||
# Builds the release artifacts of the library | ||
- name: Release build | ||
run: ./gradlew assembleRelease -x :sample:assembleRelease | ||
|
||
# Generates other artifacts (javadocJar is optional) | ||
- name: Source jar | ||
run: ./gradlew androidSourcesJar javadocJar | ||
|
||
# Runs upload, and then closes & releases the repository | ||
- name: Publish to MavenCentral | ||
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository | ||
env: | ||
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | ||
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }} | ||
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
SIGNING_SECRET_KEY_RING_FILE: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }} | ||
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
org.gradle.jvmargs=-Xmx2048m | ||
org.gradle.configureondemand=false | ||
android.useAndroidX=true | ||
libGroup=com.adevinta.android | ||
libVersion=8.1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'signing' | ||
|
||
task androidSourcesJar(type: Jar) { | ||
archiveClassifier.set('sources') | ||
if (project.plugins.findPlugin("com.android.library")) { | ||
from android.sourceSets.main.java.srcDirs | ||
from android.sourceSets.main.kotlin.srcDirs | ||
} else { | ||
from sourceSets.main.java.srcDirs | ||
from sourceSets.main.kotlin.srcDirs | ||
} | ||
} | ||
|
||
task javadocJar(type: Jar) { | ||
archiveClassifier.set('javadoc') | ||
} | ||
|
||
artifacts { | ||
archives androidSourcesJar | ||
archives javadocJar | ||
} | ||
|
||
group = project.property("libGroup") | ||
version = project.property("libVersion") | ||
|
||
afterEvaluate { | ||
publishing { | ||
publications { | ||
release(MavenPublication) { | ||
groupId project.property("libGroup") | ||
artifactId PUBLISH_ARTIFACT_ID | ||
version project.property("libVersion") | ||
|
||
if (project.plugins.findPlugin("com.android.library")) { | ||
from components.release | ||
} else { | ||
artifact("$buildDir/libs/${project.getName()}-${version}.jar") | ||
} | ||
|
||
artifact androidSourcesJar | ||
artifact javadocJar | ||
|
||
pom { | ||
name = project.project.getName() | ||
description = 'Map location picker component for Android. Based on Google Maps. An alternative to Google Place Picker.' | ||
url = 'https://github.com/AdevintaSpain/Leku' | ||
licenses { | ||
license { | ||
name = 'Stream License' | ||
url = 'https://github.com/AdevintaSpain/Leku/blob/master/LICENSE.md' | ||
} | ||
} | ||
developers { | ||
developer { | ||
id = 'AdevintaSpain' | ||
name = 'Adevinta Spain' | ||
email = 'engineers@adevinta.com' | ||
} | ||
} | ||
organization { | ||
name = "Adevinta Spain" | ||
url = "https://github.com/AdevintaSpain" | ||
} | ||
scm { | ||
connection = 'scm:git:github.com/AdevintaSpain/Leku.git' | ||
developerConnection = 'scm:git:ssh://github.com/AdevintaSpain/Leku.git' | ||
url = 'https://github.com/AdevintaSpain/Leku/tree/master' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
ext["signing.keyId"] = rootProject.ext["signing.keyId"] | ||
ext["signing.password"] = rootProject.ext["signing.password"] | ||
ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"] | ||
|
||
signing { | ||
sign publishing.publications | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Create variables with empty default values | ||
ext["ossrhUsername"] = '' | ||
ext["ossrhPassword"] = '' | ||
ext["sonatypeStagingProfileId"] = '' | ||
ext["signing.keyId"] = '0C762F0D' | ||
ext["signing.password"] = 'dsLCfZhaoHbgqgNeRHuAY' | ||
ext["signing.secretKeyRingFile"] = '../secret.gpg' | ||
|
||
File secretPropsFile = project.rootProject.file('local.properties') | ||
if (secretPropsFile.exists()) { | ||
// Read local.properties file first if it exists | ||
Properties p = new Properties() | ||
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } | ||
p.each { name, value -> ext[name] = value } | ||
} else { | ||
// Use system environment variables | ||
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') | ||
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') | ||
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') | ||
ext["signing.keyId"] = System.getenv('GPG_KEY_NAME') | ||
ext["signing.password"] = System.getenv('GPG_PASSPHRASE') | ||
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE') | ||
} | ||
|
||
// Set up Sonatype repository | ||
nexusPublishing { | ||
repositories { | ||
sonatype { | ||
stagingProfileId = sonatypeStagingProfileId | ||
username = ossrhUsername | ||
password = ossrhPassword | ||
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) | ||
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.