Skip to content

Commit

Permalink
Merge pull request #3 from pseudoankit/publish-maven-central
Browse files Browse the repository at this point in the history
publish to maven central
  • Loading branch information
pseudoankit authored Feb 9, 2024
2 parents 9620e21 + 05c3087 commit 9b72c92
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 3 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish

# This block defines that action will be triggered when we do a github release
on:
release:
types: [ created ]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup JDK
uses: actions/setup-java@v1
with:
java-version: 17

- name: Publish Artifact
env:
# fetching the release version tag
RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
OSS_USERNAME: ${{ secrets.OSS_USERNAME }}
OSS_PASSWORD: ${{ secrets.OSS_PASSWORD }}
OSS_STAGING_PROFILE_ID: ${{ secrets.OSS_STAGING_PROFILE_ID }}
OSS_SIGNING_KEY_ID: ${{ secrets.OSS_SIGNING_KEY_ID }}
OSS_SIGNING_PASSWORD: ${{ secrets.OSS_SIGNING_PASSWORD }}
OSS_SIGNING_KEY: ${{ secrets.OSS_SIGNING_KEY }}
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dependencies {
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
implementation "androidx.compose.material:material:$compose_ui_version"

implementation 'com.github.pseudoankit:RatingBarCompose:v1.0'
implementation 'io.github.pseudoankit:rating-bar:1.0.0'

// implementation project(':rating-bar')
// implementation project(':rating-bar')
}
14 changes: 14 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,22 @@ buildscript {

plugins {
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
}

task clean(type: Delete) {
delete rootProject.buildDir
}

nexusPublishing {
repositories {
sonatype {
username = System.getenv("OSS_USERNAME")
password = System.getenv("OSS_PASSWORD")
stagingProfileId = System.getenv("OSS_STAGING_PROFILE_ID")

nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
75 changes: 75 additions & 0 deletions gradle/publish-package.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

ext {
GROUP_ID = "io.github.pseudoankit"
VERSION = (System.getenv("RELEASE_TAG_NAME") ?: "SNAPSHOT").replace("v", "")

SITE_URL = 'https://github.com/pseudoankit/ratingbar-compose'
GIT_URL = 'https://github.com/pseudoankit/ratingbar-compose.git'

POM_DESCRIPTION = "Compose library to add rating bar"
POM_URL = SITE_URL
}

signing {
useInMemoryPgpKeys(
System.getenv("OSS_SIGNING_KEY_ID"),
System.getenv("OSS_SIGNING_KEY"),
System.getenv("OSS_SIGNING_PASSWORD"),
)
sign publishing.publications
}

// If you want to publish your sources as well
task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
}

artifacts {
archives androidSourcesJar
}

afterEvaluate {
publishing {
publications {
release(MavenPublication) {

groupId GROUP_ID
artifactId ARTIFACT_ID
version VERSION

from components.release
artifact androidSourcesJar

pom {
name = ARTIFACT_ID
description = POM_DESCRIPTION
url = POM_URL
licenses {
license {
name = "The Apache Software License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
}
}

developers {
developer {
id = 'pseudoankit'
name = 'Ankit Kumar'
email = '[email protected]'
}
}

scm {
connection = GIT_URL
developerConnection = GIT_URL
url = SITE_URL
}
}
}
}
}
}
5 changes: 5 additions & 0 deletions rating-bar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ plugins {
id 'org.jetbrains.kotlin.android'
}

apply from: '../gradle/publish-package.gradle'
ext {
ARTIFACT_ID = "rating-bar"
}

android {
namespace 'pseudoankit.droid.rating_bar'
compileSdk 33
Expand Down
1 change: 0 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
rootProject.name = "ComposeRatingBar"
Expand Down

0 comments on commit 9b72c92

Please sign in to comment.