-
Notifications
You must be signed in to change notification settings - Fork 129
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 (#115)
Initial work to publish to Maven Central Co-authored-by: Drew Hannay <[email protected]>
- Loading branch information
1 parent
269b863
commit 8e98ad5
Showing
12 changed files
with
299 additions
and
225 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 }} | ||
SPYGLASS_GPG_PRIVATE_KEY: ${{ secrets.SPYGLASS_GPG_PRIVATE_KEY }} | ||
SPYGLASS_GPG_PRIVATE_KEY_PASSWORD: ${{ secrets.SPYGLASS_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,23 +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 bintrayUpload` | ||
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. | ||
|
||
First, you will need a Bintray account with access to the [linkedin-spyglass](https://bintray.com/linkedin-spyglass) organization. | ||
|
||
Then, set the following environment variables: | ||
|
||
* `BINTRAY_USER` - Bintray username | ||
* `BINTRAY_KEY` - Bintray API key for the given user account | ||
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 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,88 @@ | ||
// 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 = 'Spyglass' | ||
description = 'Flexible library extending EditText to support mentions on Android.' | ||
url = 'https://github.com/linkedin/Spyglass' | ||
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/Spyglass.git' | ||
developerConnection = 'scm:git:ssh://github.com:linkedin/Spyglass.git' | ||
url = 'https://github.com/linkedin/Spyglass/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 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
// SPYGLASS_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("SPYGLASS_GPG_PRIVATE_KEY") | ||
def signingPassword = System.getenv("SPYGLASS_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 @@ | ||
#Wed Sep 26 10:14:49 PDT 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-5.6.3-all.zip |
Oops, something went wrong.