Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

Commit

Permalink
feat(java): java bindings (#50)
Browse files Browse the repository at this point in the history
* feat(kotlin): rust binding

Signed-off-by: Yuhang Shi <[email protected]>

* [skip ci] cleanup

Signed-off-by: Yuhang Shi <[email protected]>

* initial

Signed-off-by: Yuhang Shi <[email protected]>

* [skip ci]

Signed-off-by: Yuhang Shi <[email protected]>

* ; publish

Signed-off-by: Yuhang Shi <[email protected]>

* ;

Signed-off-by: Yuhang Shi <[email protected]>

* rename

Signed-off-by: Yuhang Shi <[email protected]>

* [skip ci]

Signed-off-by: Yuhang Shi <[email protected]>

* bump: flappy

Signed-off-by: Yuhang Shi <[email protected]>

* fix: server-id

Signed-off-by: Yuhang Shi <[email protected]>

* ;

Signed-off-by: Yuhang Shi <[email protected]>

* ;;;

Signed-off-by: Yuhang Shi <[email protected]>

* [skip ci] fix: last

Signed-off-by: Yuhang Shi <[email protected]>

* ;

Signed-off-by: Yuhang Shi <[email protected]>

* refactor

Signed-off-by: Yuhang Shi <[email protected]>

* sandbox

Signed-off-by: Yuhang Shi <[email protected]>

* refactor

Signed-off-by: Yuhang Shi <[email protected]>

* chore: update readme

Signed-off-by: Yuhang Shi <[email protected]>

* ; deploy

Signed-off-by: Yuhang Shi <[email protected]>

* ; publish

Signed-off-by: Yuhang Shi <[email protected]>

* ; javadoc and source

Signed-off-by: Yuhang Shi <[email protected]>

* ;

Signed-off-by: Yuhang Shi <[email protected]>

* ; gpg

Signed-off-by: Yuhang Shi <[email protected]>

* fix: last

Signed-off-by: Yuhang Shi <[email protected]>

* fix: ci

Signed-off-by: Yuhang Shi <[email protected]>

* feat: flapp prefix

Signed-off-by: Yuhang Shi <[email protected]>

* remove path-ignore

Signed-off-by: Yuhang Shi <[email protected]>

---------

Signed-off-by: Yuhang Shi <[email protected]>
  • Loading branch information
Yuhang Shi authored Oct 13, 2023
1 parent 45cc1a3 commit 7fd940a
Show file tree
Hide file tree
Showing 48 changed files with 2,605 additions and 54 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/csharp-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@ on:
push:
branches: [ main ]
paths:
- "**/*.cs"
- "**/*.csproj"
- "**/*.sln"
- "examples/csharp/**/*"
- "packages/csharp/**/*"
- ".github/workflows/csharp-*"
- ".github/workflows/csharp-publish.yml"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/csharp-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ on:
workflow_dispatch:
push:
paths:
- "**/*.cs"
- "**/*.csproj"
- "**/*.sln"
- "examples/csharp/**/*"
- "packages/csharp/**/*"
- ".github/workflows/csharp-*"
- ".github/workflows/csharp-test.yml"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
178 changes: 178 additions & 0 deletions .github/workflows/java-bindings-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@

name: Java Bindings Publish

on:
workflow_dispatch:
push:
branches: [main]
paths:
- 'packages/rust-core/java/pom.xml'

defaults:
run:
working-directory: packages/rust-core/java

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
check_if_need_release:
runs-on: ubuntu-latest
outputs:
release: ${{ steps.compare_version.outputs.release }}
steps:
- uses: actions/checkout@v4

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'

- name: Compare version
id: compare_version
run: |
new_version=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
versions=$(curl https://repo1.maven.org/maven2/com/pleisto/flappy/maven-metadata.xml | awk -F'[><]' '/<version>/{print $3}')
echo "current version: $new_version"
echo $versions
if [ -z "${versions[@]}" ]; then
echo "version is empty"
exit 1
fi
if [[ "${versions[@]}" =~ "${new_version}" ]]; then
echo "Version is exist."
echo "release=no" >> "$GITHUB_OUTPUT"
else
echo "Version is not exist."
echo "release=yes" >> "$GITHUB_OUTPUT"
fi
stage-snapshot:
runs-on: ${{ matrix.os }}
timeout-minutes: 60
needs: [check_if_need_release]
if: needs.check_if_need_release.outputs.release == 'yes'
environment:
name: Maven
strategy:
matrix:
include:
- os: ubuntu-latest
classifier: linux-x86_64
- os: windows-latest
classifier: windows-x86_64
- os: macos-latest
classifier: osx-x86_64
- os: macos-latest
classifier: osx-aarch_64
steps:
- uses: actions/checkout@v4

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Local staging
shell: bash
run: |
./mvnw verify org.sonatype.plugins:nexus-staging-maven-plugin:deploy \
-DskipTests=true \
-Djni.classifier=${{ matrix.classifier }} \
-Dcargo-build.profile=release \
-DaltStagingDirectory=local-staging \
-DskipRemoteStaging=true \
-DserverId=ossrh \
-DnexusUrl=https://s01.oss.sonatype.org
env:
MAVEN_USERNAME: ${{ vars.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYPASSWORD }}

- name: Upload local staging directory
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.classifier }}-local-staging
path: packages/rust-core/java/local-staging
if-no-files-found: error

deploy-staged-snapshots:
runs-on: ubuntu-latest
needs: [check_if_need_release, stage-snapshot]
if: needs.check_if_need_release.outputs.release == 'yes'
timeout-minutes: 60
environment:
name: Maven
steps:
- uses: actions/checkout@v4

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '8'
cache: 'maven'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Prepare environment variables
run: echo "LOCAL_STAGING_DIR=$HOME/local-staging" >> $GITHUB_ENV

- name: Download windows staging directory
uses: actions/download-artifact@v3
with:
name: windows-x86_64-local-staging
path: ~/windows-x86_64-local-staging
- name: Download linux staging directory
uses: actions/download-artifact@v3
with:
name: linux-x86_64-local-staging
path: ~/linux-x86_64-local-staging
- name: Download darwin staging directory
uses: actions/download-artifact@v3
with:
name: osx-x86_64-local-staging
path: ~/osx-x86_64-local-staging
- name: Download darwin (aarch64) staging directory
uses: actions/download-artifact@v3
with:
name: osx-aarch_64-local-staging
path: ~/osx-aarch_64-local-staging

- name: Merge staging repositories
run: |
bash tools/merge_local_staging.sh $LOCAL_STAGING_DIR/staging \
~/windows-x86_64-local-staging/staging \
~/linux-x86_64-local-staging/staging \
~/osx-x86_64-local-staging/staging \
~/osx-aarch_64-local-staging/staging
- name: Deploy local staged artifacts
run: |
./mvnw org.sonatype.plugins:nexus-staging-maven-plugin:deploy-staged \
-DaltStagingDirectory=$LOCAL_STAGING_DIR \
-DskipStagingRepositoryClose=true \
-DserverId=ossrh \
-DnexusUrl=https://s01.oss.sonatype.org
env:
MAVEN_USERNAME: ${{ vars.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYPASSWORD }}
43 changes: 43 additions & 0 deletions .github/workflows/java-bindings-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Java Bindings Test

on:
workflow_dispatch:
push:
paths:
- 'packages/rust-core/common/**'
- 'packages/rust-core/java/**'
- 'packages/rust-core/Cargo.toml'
- '.github/workflows/java-bindings-test.yml'

defaults:
run:
working-directory: packages/rust-core/java

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
ci:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
os:
- ubuntu-latest
# - macos-latest
# - windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '8'
cache: 'maven'

- name: Install
run: ./mvnw clean install -DskipTests -Dgpg.skip

- name: Test
run: ./mvnw verify -Dgpg.skip
23 changes: 7 additions & 16 deletions .github/workflows/kotlin-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ on:
description: 'type'
options:
- all
- github-page-only
- github-package-only
- maven-central-only
push:
branches: [main]
paths:
- 'packages/kotlin/flappy/gradle.properties'

defaults:
run:
working-directory: packages/kotlin

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
Expand All @@ -36,36 +39,24 @@ jobs:
uses: gradle/wrapper-validation-action@v1

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/gradle-build-action@v2.9.0
with:
gradle-version: wrapper

- name: Publish document
run: ./gradlew dokkaHtml
working-directory: packages/kotlin

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.type == 'all' || github.event.inputs.type == 'github-page-only' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
destination_dir: kotlin
publish_dir: packages/kotlin/flappy/build/dokka/dokkaHtml
keep_files: true

- name: Publish to maven central
run: ./gradlew publishAllPublicationsToMavenCentral --no-configuration-cache
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.type == 'all' || github.event.inputs.type == 'maven-central-only' }}
working-directory: packages/kotlin
env:
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY}}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYPASSWORD}}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD}}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{vars.ORG_GRADLE_PROJECT_MAVENCENTRALUSERNAME}}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{secrets.ORG_GRADLE_PROJECT_MAVENCENTRALPASSWORD}}

- name: Publish to github packages
run: ./gradlew publishAllPublicationsToGitHubPackageRepository
working-directory: packages/kotlin
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.type == 'all' || github.event.inputs.type == 'github-package-only' }}
env:
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY}}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/kotlin-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ on:
workflow_dispatch:
push:
paths:
- '**/*.kt'
- '**/*.kts'
- '**/*.java'
- 'packages/kotlin/**'
- 'examples/kotlin/**'
- 'examples/java/**'
- '.github/workflows/kotlin-test.yml'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
cache: gradle

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/gradle-build-action@v2.9.0
with:
gradle-version: wrapper

Expand Down
6 changes: 3 additions & 3 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ Flappyは、OpenAIのCode Interpreterに似た機能も提供します。これ
Flappyを始めるためには、以下のリストから好みの言語実装を選んでください:

- [Node.js](./packages/nodejs/README.md)
- [Kotlin](./packages/kotlin/README.md)
- [Python](./packages/python/README.md)
- [Kotlin&Java](./packages/kotlin/README.md)
- Ruby (近日公開)
- PHP (近日公開)
- Java (近日公開)
- [C#](./packages/csharp/README.md)
- Go (近日公開)
- Python (近日公開)

## 貢献

Expand Down
6 changes: 3 additions & 3 deletions README.zh-Hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ Flappy 还提供了类似于 OpenAI 的代码解释器的功能。它在**生产
要开始使用 Flappy,请从下面的列表中选择你所需要的语言实现:

- [Node.js](./packages/nodejs/README.md)
- [Kotlin](./packages/kotlin/README.md)
- [Python](./packages/python/README.md)
- [Kotlin&Java](./packages/kotlin/README.md)
- Ruby(即将推出)
- PHP(即将推出)
- Java(即将推出)
- [C#](./packages/csharp/README.md)
- Go(即将推出)
- Python(即将推出)

## 贡献

Expand Down
3 changes: 3 additions & 0 deletions docs/docs/code-interpreter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ void agent.callCodeInterpreter(
<TabItem value="java" label="Java" default>
Coming soon
</TabItem>
<TabItem value="kotlin" label="Kotlin" default>
Coming soon
</TabItem>
<TabItem value="csharp" label="C#" default>
Coming soon
</TabItem>
Expand Down
Loading

0 comments on commit 7fd940a

Please sign in to comment.