Skip to content

Commit

Permalink
Release pipeline setup
Browse files Browse the repository at this point in the history
  • Loading branch information
kishan-cashfree committed Mar 13, 2024
1 parent f4bfaa1 commit e1e1bf3
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 7 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ jobs:
- name: Build with Gradle
run: ./gradlew build

# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
# the publishing section of your build.gradle
- name: Publish to GitHub Packages
run: ./gradlew publish
- name: Publish package
run: ./gradlew clean build publishSDKPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository
env:
USERNAME: ${{ github.actor }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
10 changes: 9 additions & 1 deletion PaymentIcons/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
plugins {
id("java-library")
id("java")
id("org.jetbrains.kotlin.jvm")
}

extra.apply {
set("PUBLISH_GROUP_ID", "com.cashfree.pg")
set("PUBLISH_ARTIFACT_ID", "icons")
set("PUBLISH_VERSION", "1.0.0")
}

apply(from = "${rootProject.projectDir}/scripts/publish-module.gradle")

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies {
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.10.0")
implementation(project(":PaymentIcons"))
//implementation("com.cashfree.pg:icons:1.0.0")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
Expand Down
11 changes: 11 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,15 @@ plugins {
id("com.android.application") version "8.1.1" apply false
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
id("org.jetbrains.kotlin.jvm") version "1.9.0" apply false
id("io.github.gradle-nexus.publish-plugin") version "1.1.0" apply true
}

nexusPublishing {
repositories {
sonatype {
stagingProfileId.set(System.getenv("SONATYPE_STAGING_PROFILE_ID"))
username.set(System.getenv("MAVEN_USERNAME"))
password.set(System.getenv("MAVEN_PASSWORD"))
}
}
}
119 changes: 119 additions & 0 deletions scripts/publish-module.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

tasks.register('sourcesJar', Jar) {
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
// For Android libraries
from android.sourceSets.main.java.srcDirs
from android.sourceSets.main.kotlin.srcDirs
} else {
// For pure Kotlin libraries, in case you have them
from sourceSets.main.java.srcDirs
from sourceSets.main.kotlin.srcDirs
}
}

tasks.register('packageJavadoc', Jar) {
archiveClassifier.set('javadoc')
from javadoc.destinationDir
}

artifacts {
archives sourcesJar
archives packageJavadoc
}

group = PUBLISH_GROUP_ID
version = PUBLISH_VERSION

afterEvaluate {
publishing {
publications {
SDK(MavenPublication) {
// The coordinates of the library, being set from variables that
// we'll set up later
groupId PUBLISH_GROUP_ID
artifactId PUBLISH_ARTIFACT_ID
version PUBLISH_VERSION

if (project.plugins.findPlugin("com.android.library")) {
from components.release
} else {
from components.java
}

artifact sourcesJar
artifact packageJavadoc

// Mostly self-explanatory metadata
pom {
name = PUBLISH_ARTIFACT_ID
description = 'Cashfree Payments, Payment Icon library'
url = 'https://github.com/cashfree/payments-icons-java'
licenses {
license {
name = 'MIT License'
}
}
developers {
developer {
id = 'developers.cashfree'
name = 'Cashfree Payments'
email = 'developers@cashfree.com'
}
}

scm {
connection = 'scm:git:github.com:cashfree/payments-icons-java.git'
developerConnection = 'scm:git:ssh://github.com:cashfree/payments-icons-java.git'
url = 'https://github.com/cashfree/payments-icons-java'
}

withXml {
Node pomNode = asNode()
pomNode.dependencies.'*'.each() {
it.parent().remove(it)
}
pomNode.remove(pomNode.dependencies)
def dependenciesNode = asNode().appendNode('dependencies')
// Iterate over the api dependencies (we don't want the test ones), adding a <dependency> node for each
configurations.implementation.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
dependencyNode.appendNode('scope', "compile")
}
configurations.api.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
dependencyNode.appendNode('scope', "compile")
}
}
}
}
}
repositories {
maven {
name = "OSSRH"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
}
}

signing {
useInMemoryPgpKeys(
System.getenv("SIGNING_KEY_ID"),
System.getenv("SIGNING_KEY"),
System.getenv("SIGNING_PASSWORD")
)
sign publishing.publications
}
6 changes: 6 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ pluginManagement {
google()
mavenCentral()
gradlePluginPortal()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
}

Expand Down

0 comments on commit e1e1bf3

Please sign in to comment.