-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated deployment to use Maven Central & Prepared for a 2.1.0 (Central) release
- Loading branch information
1 parent
96ca157
commit 91808f7
Showing
8 changed files
with
224 additions
and
130 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,27 @@ | ||
name: "Release" | ||
|
||
on: | ||
release: | ||
types: [released] | ||
|
||
jobs: | ||
publish: | ||
name: "Release" | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v2 | ||
- name: "Setup JDK" | ||
uses: actions/setup-java@v2 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '11' | ||
cache: 'gradle' | ||
- name: "Build & Release" | ||
run: ./gradlew clean library:assembleRelease androidJavaDocJar androidSourcesJar generatePomFileForNexusPublication publishNexusPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository | ||
env: | ||
SONATYPE_TOKEN_USERNAME: ${{ secrets.SONATYPE_TOKEN_USERNAME }} | ||
SONATYPE_TOKEN_PASSWORD: ${{ secrets.SONATYPE_TOKEN_PASSWORD }} | ||
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} | ||
SIGNING_KEY: ${{ secrets.SIGNING_KEY }} | ||
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_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
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 @@ | ||
class LibraryInfo { | ||
String artifactId | ||
String groupId | ||
|
||
Integer versionMajor | ||
Integer versionMinor | ||
Integer versionPatch | ||
String versionName | ||
} | ||
|
||
def readLibraryProps() { | ||
def versionProps = new Properties() | ||
def file = new File("$projectDir/libraryInfo.properties") | ||
versionProps.load(file.newInputStream()) | ||
|
||
return versionProps | ||
} | ||
|
||
def getLibraryInfo() { | ||
def props = readLibraryProps() | ||
LibraryInfo info = new LibraryInfo() | ||
|
||
info.artifactId = props.get('ARTIFACT_ID') as String | ||
info.groupId = props.get('GROUP_ID') as String | ||
|
||
info.versionMajor = props.get('VERSION_MAJOR') as Integer | ||
info.versionMinor = props.get('VERSION_MINOR') as Integer | ||
info.versionPatch = props.get('VERSION_PATCH') as Integer | ||
info.versionName = "${info.versionMajor}.${info.versionMinor}.${info.versionPatch}" | ||
|
||
return info | ||
} | ||
|
||
ext { | ||
getLibraryInfo = this.&getLibraryInfo | ||
} |
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,117 @@ | ||
|
||
apply plugin: "maven-publish" | ||
apply plugin: "signing" | ||
|
||
task androidJavaDoc(type: Javadoc) { | ||
source = android.sourceSets.main.java.srcDirs | ||
classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) | ||
options.encoding "UTF-8" | ||
options.charSet 'UTF-8' | ||
options.author true | ||
options.version true | ||
failOnError false | ||
} | ||
|
||
task androidJavaDocJar(type: Jar, dependsOn: androidJavaDoc) { | ||
archiveClassifier.set('javadoc') | ||
from androidJavaDoc.destinationDir | ||
} | ||
|
||
task androidSourcesJar(type: Jar) { | ||
archiveClassifier.set('sources') | ||
from android.sourceSets.main.java.srcDirs | ||
} | ||
|
||
/** | ||
* Helper to add dependencies to the POM node. This is needed during manual construction | ||
* of the dependencies block | ||
*/ | ||
static def addPomDependency(groovy.util.Node dependenciesNode, Dependency dependency, String dependencyScope) { | ||
// Ignore incomplete dependencies | ||
if (dependency.name == null || dependency.name == 'unspecified' || dependency.group == null || dependency.version == null) { | ||
return | ||
} | ||
|
||
def dependencyNode = dependenciesNode.appendNode('dependency') | ||
dependencyNode.appendNode('groupId', dependency.group) | ||
dependencyNode.appendNode('artifactId', dependency.name) | ||
dependencyNode.appendNode('version', dependency.version) | ||
dependencyNode.appendNode('scope', dependencyScope) | ||
} | ||
|
||
/** | ||
* Deploy to Maven Central (Sonatype) | ||
* `$ ./gradlew clean library:assembleRelease androidJavaDocJar androidSourcesJar generatePomFileForNexusPublication publishNexusPublicationToSonatypeRepository closeSonatypeStagingRepository` | ||
* | ||
* ** NOTE: ** | ||
* This expects the following environment variables to be present | ||
* - `SONATYPE_TOKEN_USERNAME` : The username for the user token in Sonatype | ||
* - `SONATYPE_TOKEN_PASSWORD` : The password for the user token in Sonatype | ||
* - `SIGNING_KEY_ID` : The ID for the GPG signing key to sign the library with | ||
* - `SIGNING_KEY` : The GPG key to sign the library with | ||
* - `SIGNING_KEY_PASSWORD` : The password for the `SIGNING_KEY` | ||
*/ | ||
publishing { | ||
publications { | ||
nexus(MavenPublication) { | ||
groupId rootProject.ext.libraryInfo.groupId | ||
artifactId rootProject.ext.libraryInfo.artifactId | ||
version rootProject.ext.libraryInfo.versionName | ||
|
||
artifact bundleReleaseAar | ||
artifact androidJavaDocJar | ||
artifact androidSourcesJar | ||
|
||
pom { | ||
name = rootProject.ext.libraryInfo.groupId + ":" + rootProject.ext.libraryInfo.artifactId | ||
description = "A media playback management library for Android" | ||
url = "https://github.com/brianwernick/PlaylistCore" | ||
licenses { | ||
license { | ||
name = "The Apache License, Version 2.0" | ||
url = "http://www.apache.org/licenses/LICENSE-2.0.txt" | ||
} | ||
} | ||
scm { | ||
connection = 'scm:git:github.com/brianwernick/PlaylistCore.git' | ||
developerConnection = 'scm:git:ssh://github.com/brianwernick/PlaylistCore.git' | ||
url = 'https://github.com/brianwernick/PlaylistCore/tree/main' | ||
} | ||
developers { | ||
developer { | ||
name = 'Brian Wernick' | ||
email = '[email protected]' | ||
organization = 'DevBrackets' | ||
organizationUrl = 'https://devbrackets.com' | ||
} | ||
} | ||
|
||
// The generated POM doesn't include dependencies when building Android artifacts, so we manually | ||
// add the dependencies to the POM here | ||
withXml { | ||
def dependenciesNode = asNode().appendNode('dependencies') | ||
|
||
// Iterate over the implementation dependencies, adding a <dependency> node for each | ||
configurations.implementation.dependencies.each { | ||
addPomDependency(dependenciesNode, it, "runtime") | ||
} | ||
|
||
// Iterate over the api dependencies, adding a <dependency> node for each | ||
configurations.api.dependencies.each { | ||
addPomDependency(dependenciesNode, it, "compile") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
useInMemoryPgpKeys( | ||
System.getenv("SIGNING_KEY_ID"), | ||
System.getenv("SIGNING_KEY"), | ||
System.getenv("SIGNING_KEY_PASSWORD"), | ||
) | ||
|
||
sign publishing.publications.nexus | ||
} |
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.
Oops, something went wrong.