-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up publishing for Maven Central (#56)
Initial work to publish to Maven Central
- Loading branch information
1 parent
7a5a8c4
commit 7755478
Showing
14 changed files
with
233 additions
and
229 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,35 @@ | ||
name: Deploy snapshot | ||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
if: ${{ !contains(github.event.head_commit.message, 'Prepare for release') }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Cache Gradle Files | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/.gradle/caches/ | ||
~/.gradle/wrapper/ | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Set up Java | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 1.8 | ||
|
||
- name: Build | ||
run: ./gradlew build | ||
|
||
- name: Publish package | ||
run: ./gradlew publishAllPublicationsToSonatypeSnapshotRepository | ||
env: | ||
SONATYPE_USER: ${{ secrets.SONATYPE_USER }} | ||
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} |
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,27 @@ | ||
name: Publish package to the Maven Central Repository | ||
on: | ||
release: | ||
types: [published] | ||
branches: | ||
- master | ||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Java | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 1.8 | ||
|
||
- name: Build | ||
run: ./gradlew build | ||
|
||
- name: Publish package | ||
run: ./gradlew publishAllPublicationsToMavenCentralRepository | ||
env: | ||
SONATYPE_USER: ${{ secrets.SONATYPE_USER }} | ||
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} | ||
SHAKY_ANDROID_GPG_PRIVATE_KEY: ${{ secrets.SHAKY_ANDROID_GPG_PRIVATE_KEY }} | ||
SHAKY_ANDROID_GPG_PRIVATE_KEY_PASSWORD: ${{ secrets.SHAKY_ANDROID_GPG_PRIVATE_KEY_PASSWORD }} |
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,21 +1,24 @@ | ||
Releasing | ||
======== | ||
# Releasing | ||
|
||
1. Change the version in `gradle.properties` to a non-SNAPSHOT version. | ||
2. Update the `CHANGELOG.md` for the impending release. | ||
3. Update the `README.md` with the new version. | ||
4. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version) | ||
5. `git tag -a X.Y.Z -m "Version X.Y.Z"` (where X.Y.Z is the new version) | ||
6. `./gradlew clean distributeBuild` | ||
7. Update the `gradle.properties` to the next SNAPSHOT version. | ||
8. `git commit -am "Prepare next development version."` | ||
9. `git push && git push --tags` | ||
1. Change the version in `gradle.properties` to a non-SNAPSHOT version. | ||
2. Update the `CHANGELOG.md` for the impending release. | ||
3. Update the `README.md` with the new version. | ||
4. `git commit -am "Prepare for release X.Y.Z."` (where X.Y.Z is the new version) | ||
5. `git tag -a X.Y.Z -m "Version X.Y.Z"` (where X.Y.Z is the new version) | ||
6. Update the `gradle.properties` to the next SNAPSHOT version. | ||
7. `git commit -am "Prepare next development version."` | ||
8. `git push && git push --tags` | ||
9. Create a new release in the releases tab on GitHub | ||
10. Wait for the [publish-maven-central.yml](.github/workflows/publish-maven-central.yml) action to complete. | ||
11. Visit [Sonatype Nexus](https://oss.sonatype.org/) and promote the artifact. | ||
|
||
## How it works | ||
|
||
Prerequisites | ||
------------- | ||
The [deploy-snapshot.yml](.github/workflows/deploy-snapshot.yml) workflow runs on every | ||
push to the main branch as long as the commit message does not contain `Prepare for release`. This | ||
workflow calls Gradle to publish to the Sonatype snapshot repository. | ||
|
||
Set the following environment variables: | ||
|
||
* `ARTIFACTORY_USER` - LinkedIn artifactory username for releasing to `com.linkedin.shaky`. | ||
* `ARTIFACTORY_KEY` - LinkedIn artifactory API key for releasing to `com.linkedin.shaky`. | ||
For actual releases, there is a separate [publish-maven-central.yml](.github/workflows/publish-maven-central.yml) | ||
workflow which runs after a new release is created in the GitHub UI. This will call Gradle on the | ||
tagged release commit and upload to the staging repository. After that completes, you will need to | ||
go and promote the artifacts to production. |
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 was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
buildSrc/src/main/groovy/com/linkedin/gradle/DistributeTask.groovy
This file was deleted.
Oops, something went wrong.
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,6 +1,22 @@ | ||
# Project-wide Gradle settings. | ||
# IDE (e.g. Android Studio) users: | ||
# Gradle settings configured through the IDE *will override* | ||
# any settings specified in this file. | ||
# For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 | ||
|
||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true | ||
|
||
# AndroidX package structure to make it clearer which packages are bundled with the | ||
# Android operating system, and which are packaged with your app"s APK | ||
# https://developer.android.com/topic/libraries/support-library/androidx-rn | ||
android.useAndroidX=true | ||
|
||
GROUP_ID=com.linkedin.shaky | ||
ARTIFACT=shaky | ||
VERSION_NAME=3.0.2-SNAPSHOT | ||
LIBRARY_NAME=Shaky | ||
LIBRARY_DESCRIPTION=Shake-to-send-feedback library for Android | ||
android.useAndroidX=true |
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,91 @@ | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'signing' | ||
|
||
// Ideally AGP should provide sources and javadoc integration for their components: | ||
// https://issuetracker.google.com/issues/145670440 | ||
tasks.register("sourcesJar", Jar) { | ||
classifier 'sources' | ||
from android.sourceSets.main.java.srcDirs | ||
} | ||
|
||
tasks.register("javadoc", Javadoc) { | ||
failOnError false | ||
source = android.sourceSets.main.java.srcDirs | ||
classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) | ||
} | ||
|
||
tasks.register("javadocJar", Jar) { | ||
dependsOn javadoc | ||
classifier 'javadoc' | ||
from javadoc.destinationDir | ||
} | ||
|
||
// AGP creates the components in afterEvaluate, so we need to use it too | ||
// https://developer.android.com/studio/build/maven-publish-plugin | ||
afterEvaluate { | ||
publishing { | ||
publications { | ||
maven(MavenPublication) { | ||
from components.release | ||
|
||
artifact sourcesJar | ||
artifact javadocJar | ||
|
||
pom { | ||
name = 'Shaky' | ||
description = 'Shake-to-send-feedback library for Android' | ||
url = 'https://github.com/linkedin/shaky-android' | ||
licenses { | ||
license { | ||
name = 'The Apache Software License, Version 2.0' | ||
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' | ||
} | ||
} | ||
developers { | ||
developer { | ||
id = 'com.linkedin' | ||
name = 'LinkedIn Corp' | ||
} | ||
} | ||
scm { | ||
connection = 'scm:git:git://github.com/linkedin/shaky-android.git' | ||
developerConnection = 'scm:git:ssh://github.com:linkedin/shaky-android.git' | ||
url = 'https://github.com/linkedin/shaky-android/tree/master' | ||
} | ||
} | ||
|
||
repositories { | ||
def sonatypeUsername = System.getenv("SONATYPE_USER") | ||
def sonatypePassword = System.getenv("SONATYPE_PASSWORD") | ||
maven { | ||
name = "sonatypeSnapshot" | ||
url = "https://oss.sonatype.org/content/repositories/snapshots" | ||
credentials { | ||
username = sonatypeUsername | ||
password = sonatypePassword | ||
} | ||
} | ||
maven { | ||
name = "mavenCentral" | ||
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2" | ||
credentials { | ||
username = sonatypeUsername | ||
password = sonatypePassword | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// SHAKY_ANDROID_GPG_PRIVATE_KEY should contain the armoured private key that | ||
// starts with -----BEGIN PGP PRIVATE KEY BLOCK----- | ||
// It can be obtained with gpg --armour --export-secret-keys KEY_ID | ||
def signingKey = System.getenv("SHAKY_ANDROID_GPG_PRIVATE_KEY") | ||
def signingPassword = System.getenv("SHAKY_ANDROID_GPG_PRIVATE_KEY_PASSWORD") | ||
signing { | ||
required { signingKey != null && signingPassword != null } | ||
useInMemoryPgpKeys(signingKey, signingPassword) | ||
sign publishing.publications.maven | ||
} | ||
} |
Binary file not shown.
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,6 +1,5 @@ | ||
#Sat Nov 10 11:59:22 PST 2018 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip |
Oops, something went wrong.