Skip to content

Commit

Permalink
add scripts to publish
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Apr 20, 2023
1 parent 69c7bbf commit bd12eec
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 2 deletions.
22 changes: 20 additions & 2 deletions animatednavbar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ plugins {
id 'org.jetbrains.kotlin.android'
}

ext {
PUBLISH_GROUP_ID = 'com.exyte'
PUBLISH_VERSION = '1.0.0'
PUBLISH_ARTIFACT_ID = 'animated-navigation-bar'
PUBLISH_DESCRIPTION = 'navigation bar with a number of preset animations'
PUBLISH_URL = 'https://github.com/exyte/AndroidAnimatedNavigationBar'
PUBLISH_LICENSE_NAME = 'MIT License'
PUBLISH_LICENSE_URL = 'https://github.com/exyte/AndroidAnimatedNavigationBar/blob/master/LICENSE'
PUBLISH_DEVELOPER_ID = 'exyte'
PUBLISH_DEVELOPER_NAME = 'Alex Yudenkov'
PUBLISH_DEVELOPER_EMAIL = '[email protected]'
PUBLISH_SCM_CONNECTION = 'scm:git:github.com/exyte/AndroidAnimatedNavigationBar.git'
PUBLISH_SCM_DEVELOPER_CONNECTION = 'scm:git:ssh://github.com/exyte/AndroidAnimatedNavigationBar.git'
PUBLISH_SCM_URL = 'https://github.com/exyte/AndroidAnimatedNavigationBar/tree/master'
}

apply from: "publish-module.gradle"

android {
compileSdk 33

Expand Down Expand Up @@ -44,8 +62,8 @@ android {
}

dependencies {
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.core:core-ktx:1.10.0'
implementation "androidx.compose.ui:ui:$compose_ui_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
implementation 'androidx.compose.material:material:1.3.1'
implementation 'androidx.compose.material:material:1.4.1'
}
70 changes: 70 additions & 0 deletions animatednavbar/publish-module.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

tasks.register('androidSourcesJar', 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
}
}

artifacts {
archives androidSourcesJar
}

group = PUBLISH_GROUP_ID
version = PUBLISH_VERSION

afterEvaluate {
publishing {
publications {
release(MavenPublication) {
groupId PUBLISH_GROUP_ID
artifactId PUBLISH_ARTIFACT_ID
version PUBLISH_VERSION

from components.release

artifact androidSourcesJar

pom {
name = PUBLISH_ARTIFACT_ID
description = PUBLISH_DESCRIPTION
url = PUBLISH_URL
licenses {
license {
name = PUBLISH_LICENSE_NAME
url = PUBLISH_LICENSE_URL
}
}
developers {
developer {
id = PUBLISH_DEVELOPER_ID
name = PUBLISH_DEVELOPER_NAME
email = PUBLISH_DEVELOPER_EMAIL
}
}

scm {
connection = PUBLISH_SCM_CONNECTION
developerConnection = PUBLISH_SCM_DEVELOPER_CONNECTION
url = PUBLISH_SCM_URL
}
}
}
}
}
}

signing {
useInMemoryPgpKeys(
rootProject.ext["signing.keyId"],
rootProject.ext["signing.key"],
rootProject.ext["signing.password"]
)
sign publishing.publications
}
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ plugins {
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
id 'io.github.gradle-nexus.publish-plugin' version "1.3.0"
}

apply from: 'scripts/publish-root.gradle'

subprojects {
tasks.withType(KotlinCompile).configureEach {
if (project.findProperty("navBar.enableComposeCompilerReports") == "true") {
Expand Down
37 changes: 37 additions & 0 deletions scripts/publish-root.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
ext["signing.keyId"] = ''
ext["signing.password"] = ''
ext["signing.key"] = ''
ext["ossrhUsername"] = ''
ext["ossrhPassword"] = ''
ext["sonatypeStagingProfileId"] = ''


File secretPropsFile = project.rootProject.file('local.properties')
if (secretPropsFile.exists()) {
Properties p = new Properties()
new FileInputStream(secretPropsFile).withCloseable { is ->
p.load(is)
}
p.each { name, value ->
ext[name] = value
}
} else {
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('SIGNING_KEY_ID')
ext['signing.password'] = System.getenv('SIGNING_PASSWORD')
ext["signing.key"] = System.getenv('SIGNING_KEY')
}

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/"))
}
}
}

0 comments on commit bd12eec

Please sign in to comment.