-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial Java SDK build and release workflow
This commit sets up the GitHub Actions workflow for the Java SDK build and release process, targeting JDK 21. Added necessary configuration files, including build scripts, wrapper, settings, and license documents to enable continuous integration and seamless integration for Kody Java gRPC Client.
- Loading branch information
0 parents
commit d83e43a
Showing
21 changed files
with
1,348 additions
and
0 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,89 @@ | ||
name: Java SDK Build & Release JDK21 | ||
|
||
on: | ||
repository_dispatch: | ||
types: [tag-push] | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: 'source tag' | ||
required: true | ||
type: string | ||
env: | ||
GITHUB_ACTOR: ${{ github.actor }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_REPOSITORY: ${{ github.repository }} | ||
jobs: | ||
validation: | ||
name: "gradle-wrapper-validation" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: gradle/actions/wrapper-validation@v3 | ||
|
||
tagging: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
tag: ${{ env.tag }} | ||
version: ${{ env.version }} | ||
prerelease: ${{ env.prerelease }} | ||
steps: | ||
- name: Use the tag from the event | ||
id: tag | ||
run: | | ||
TAG="${{ inputs.tag || github.event.client_payload.tag }}" | ||
VERSION=${TAG#v} | ||
echo "TAG from event: ${TAG}" | ||
echo "tag=${TAG}" >> $GITHUB_ENV | ||
echo "version=${VERSION}">> $GITHUB_ENV | ||
if [[ "${TAG}" == *-* ]]; then echo "prerelease=true" >> $GITHUB_ENV; else echo "prerelease=false" >> $GITHUB_ENV; fi | ||
publish: | ||
needs: | ||
- validation | ||
- tagging | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Checkout proto repository | ||
run: | | ||
git clone https://github.com/KodyPay/kp-protocols-clientsdk.git proto-repo | ||
mv proto-repo/src . | ||
rm -r proto-repo | ||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '21' | ||
distribution: 'adopt' | ||
- name: Setup & Build Gradle | ||
uses: gradle/actions/setup-gradle@v3 | ||
with: | ||
arguments: build -s --scan -Pversion=${{ needs.tagging.outputs.version }} | ||
- name: Setup git config | ||
run: | | ||
echo "Setting up Git user information" | ||
git config --global user.name "${{github.actor}}" | ||
git config --global user.email "<>" | ||
- name: Publish candidate | ||
if: ${{ needs.tagging.outputs.prerelease }} | ||
run: ./gradlew candidate -Prelease.version=${{ needs.tagging.outputs.version }} -s | ||
- name: Publish release | ||
if: ${{ !needs.tagging.outputs.prerelease }} | ||
run: ./gradlew final -Prelease.version=${{ needs.tagging.outputs.version }} -s | ||
|
||
release: | ||
needs: | ||
- tagging | ||
- publish | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Create Release | ||
uses: ncipollo/[email protected] | ||
with: | ||
name: "${{ needs.tagging.outputs.tag }}" | ||
tag: "${{ needs.tagging.outputs.tag }}" | ||
omitBody: true | ||
draft: false | ||
prerelease: ${{ needs.tagging.outputs.prerelease }} | ||
makeLatest: ${{ !needs.tagging.outputs.prerelease }} |
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,12 @@ | ||
# Ignore Gradle project-specific cache directory | ||
.gradle | ||
|
||
# Ignore Gradle build output directory | ||
build | ||
/.idea/ | ||
/.gitattributes | ||
|
||
proto-repo/ | ||
|
||
.DS_Store | ||
/src/ |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Kody | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,54 @@ | ||
# Kody Java gRPC Client | ||
|
||
## Description | ||
|
||
The Kody Java gRPC Client is an SDK generated from protobuf protocols to facilitate communication with the Kody Payments | ||
Gateway. This library provides a simple and efficient way to integrate Kody payment functionalities into your Java | ||
applications. | ||
|
||
## Requirements | ||
|
||
- Java 21 or later | ||
- Github account | ||
- Gradle | ||
|
||
## Installation | ||
|
||
### Gradle | ||
|
||
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") | ||
} | ||
``` | ||
|
||
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: | ||
|
||
```bash | ||
export GITHUB_USERNAME=<your-github-username> | ||
export GITHUB_TOKEN=<your-github-token> | ||
``` | ||
|
||
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. | ||
|
||
## Samples | ||
|
||
Go to the [samples](https://github.com/KodyPay/kody-clientsdk-java/tree/main/samples) directory for examples on how to use the Kody Java gRPC Client. | ||
|
||
|
||
## License | ||
|
||
This project is licensed under the MIT License. |
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,83 @@ | ||
import com.google.protobuf.gradle.* | ||
|
||
plugins { | ||
id("java-library") | ||
id("com.google.protobuf") version "0.9.4" | ||
id("maven-publish") | ||
id("nebula.release") version "19.0.10" | ||
} | ||
|
||
description = "Kody Java gRPC Client" | ||
group = "com.kodypay.api.grpc" | ||
|
||
val protobufVersion = "4.27.3" | ||
val semverVersion = "0.9.0" | ||
val grpcVersion = "1.66.0" | ||
val annotationsVersion = "6.0.53" | ||
|
||
repositories { | ||
mavenCentral() | ||
google() | ||
gradlePluginPortal() | ||
} | ||
|
||
java { | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of(21)) | ||
vendor.set(JvmVendorSpec.ADOPTIUM) | ||
} | ||
} | ||
|
||
|
||
dependencies { | ||
implementation("io.grpc:grpc-protobuf:$grpcVersion") | ||
implementation("io.grpc:grpc-stub:$grpcVersion") | ||
implementation("com.google.protobuf:protobuf-java:$protobufVersion") | ||
compileOnly("org.apache.tomcat:annotations-api:$annotationsVersion") | ||
} | ||
|
||
protobuf { | ||
protoc { | ||
artifact = "com.google.protobuf:protoc:$protobufVersion" | ||
} | ||
plugins { | ||
id("grpc") { | ||
artifact = "io.grpc:protoc-gen-grpc-java:$grpcVersion" | ||
} | ||
} | ||
generateProtoTasks { | ||
all().forEach { task -> | ||
task.builtins { | ||
java {} | ||
} | ||
task.plugins { | ||
id("grpc") { | ||
outputSubDir = "java" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("gpr") { | ||
from(components["java"]) | ||
} | ||
} | ||
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") | ||
} | ||
} | ||
} | ||
} | ||
|
||
tasks.withType<PublishToMavenRepository> { | ||
mustRunAfter(rootProject.tasks.findByName("release")) | ||
rootProject.tasks.findByName("postRelease")?.dependsOn(this) | ||
} |
Binary file not shown.
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,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.