Skip to content

Commit

Permalink
[BAM-9] Publishing to Maven Central Repository, remove GH packages
Browse files Browse the repository at this point in the history
  • Loading branch information
rfontes17 committed Sep 9, 2024
1 parent d83e43a commit 7f02673
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 44 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/java-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ jobs:
- validation
- tagging
runs-on: ubuntu-latest
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralUsername }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_mavenCentralPassword }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKeyId }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKeyPassword }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_signingInMemoryKey }}
steps:
- uses: actions/checkout@v4
- name: Checkout proto repository
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ proto-repo/

.DS_Store
/src/
/test.env
31 changes: 11 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ applications.
## Requirements

- Java 21 or later
- Github account
- Gradle
- Gradle or Maven

## Installation

Expand All @@ -19,30 +18,22 @@ applications.
Add the following configuration to your `build.gradle` file:

```kts
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/KodyPay/kody-clientsdk-java-dev/")
credentials {
username = System.getenv("GITHUB_USERNAME")
password = System.getenv("GITHUB_TOKEN")
}
}
}

dependencies {
implementation("com.kodypay.api.grpc:kody-clientsdk-java:0.0.1")
implementation("com.kodypay.grpc:kody-clientsdk-java:0.0.1")
}
```

To authenticate with GitHub Packages, you need to create a personal access token with the `read:packages` scope and set it as an environment variable:
### Maven

```bash
export GITHUB_USERNAME=<your-github-username>
export GITHUB_TOKEN=<your-github-token>
```
Add the following configuration to your `pom.xml` file:

Refer to the [GitHub documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) for more information about the token.
```xml
<dependency>
<groupId>com.kodypay.grpc</groupId>
<artifactId>kody-clientsdk-java</artifactId>
<version>0.0.1</version>
</dependency>
```

## Samples

Expand Down
41 changes: 26 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import com.google.protobuf.gradle.*
import com.vanniktech.maven.publish.SonatypeHost

plugins {
id("java-library")
id("com.google.protobuf") version "0.9.4"
id("maven-publish")
id("nebula.release") version "19.0.10"
id("com.vanniktech.maven.publish") version "0.28.0"
}

description = "Kody Java gRPC Client"
group = "com.kodypay.api.grpc"
group = "com.kodypay.grpc"

val protobufVersion = "4.27.3"
val semverVersion = "0.9.0"
val grpcVersion = "1.66.0"
val annotationsVersion = "6.0.53"

Expand Down Expand Up @@ -59,21 +59,32 @@ protobuf {
}
}

publishing {
publications {
create<MavenPublication>("gpr") {
from(components["java"])
mavenPublishing {
pom {
name = "kody-clientsdk-java"
description = "Kody Java gRPC Client"
url = "https://github.com/KodyPay/kody-clientsdk-java"
inceptionYear = "2024"
licenses{
license {
name = "MIT License"
url = "https://opensource.org/licenses/MIT"
}
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/${System.getenv("GITHUB_REPOSITORY")}")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
developers {
developer {
id = "kodypay"
name = "Kody"
}
}
scm {
url = "https://github.com/KodyPay/kody-clientsdk-java"
connection = "scm:git:git://github.com/KodyPay/kody-clientsdk-java.git"
developerConnection = "scm:git:ssh://github.com/KodyPay/kody-clientsdk-java.git"
}

signAllPublications()
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
}
}

Expand Down
10 changes: 1 addition & 9 deletions samples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ repositories {
mavenCentral()
google()
gradlePluginPortal()
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/KodyPay/kody-clientsdk-java/")
credentials {
username = System.getenv("GITHUB_USERNAME")
password = System.getenv("GITHUB_TOKEN")
}
}
}


Expand All @@ -38,6 +30,6 @@ dependencies {
implementation("com.google.protobuf:protobuf-java:$protobufVersion")
implementation("org.apache.logging.log4j:log4j-slf4j2-impl:$log4jVersion")
implementation("org.apache.commons:commons-lang3:$apacheCommonsVersion")
implementation("com.kodypay.api.grpc:kody-clientsdk-java:0.0.1")
implementation("com.kodypay.grpc:kody-clientsdk-java:0.0.1")
}

0 comments on commit 7f02673

Please sign in to comment.