Skip to content

Commit

Permalink
refactor: publish jar file as a part of the github release
Browse files Browse the repository at this point in the history
  • Loading branch information
null8626 committed Jul 8, 2024
1 parent f7d7b23 commit 2013291
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 45 deletions.
87 changes: 50 additions & 37 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,51 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
java-publish:
name: Publish java binding
runs-on: ubuntu-latest
needs:
- setup
- commit
- java
if: ${{ always() && github.event_name != 'pull_request' && needs.setup.outputs.release != 'null' }}
env:
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_NAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASS }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASS }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.MAVEN_GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_VERSION: ${{ needs.setup.outputs.release }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: oracle
java-version: 21
- name: Prepare java binding
working-directory: bindings/java
run: |
unzip ./bin/bindings.zip -d ./bin
chmod +x ./gradlew
./gradlew jreleaserConfig
./gradlew clean build publish -x test
shell: bash
- name: Publish java binding
working-directory: bindings/java
run: ./gradlew jreleaserFullRelease
continue-on-error: true
shell: bash
- name: Move jar file
working-directory: bindings/java
run: mv ./build/libs/decancer-${{ needs.setup.outputs.release }}.jar ../..
shell: bash
- name: Upload jar artifact
uses: actions/upload-artifact@v4
with:
name: java-jar
path: ./decancer.jar
if-no-files-found: error
publish:
name: Publish
runs-on: ubuntu-latest
Expand All @@ -733,6 +778,7 @@ jobs:
- native-test
- commit
- pages
- java-publish
if: ${{ always() && github.event_name != 'pull_request' && needs.setup.outputs.release != 'null' }}
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -780,43 +826,10 @@ jobs:
body: "This is the GitHub Release for decancer v${{ needs.setup.outputs.release }}."
draft: false
prerelease: false
files: "*.zip"
files: |
decancer.jar
*.zip
tag_name: "v${{ needs.setup.outputs.release }}"
token: ${{ secrets.GITHUB_TOKEN }}
env:
GITHUB_REPOSITORY: null8626/decancer
publish-java:
name: Publish java binding
runs-on: ubuntu-latest
needs:
- setup
- commit
- java
if: ${{ always() && github.event_name != 'pull_request' && needs.setup.outputs.release != 'null' }}
env:
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_NAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASS }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASS }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.MAVEN_GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_VERSION: ${{ needs.setup.outputs.release }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: oracle
java-version: 21
- name: Prepare java binding
working-directory: bindings/java
run: |
unzip ./bin/bindings.zip -d ./bin
chmod +x ./gradlew
./gradlew jreleaserConfig
./gradlew clean build publish -x test
shell: bash
- name: Publish java binding
working-directory: bindings/java
run: ./gradlew jreleaserFullRelease
continue-on-error: true
shell: bash
GITHUB_REPOSITORY: null8626/decancer
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,20 @@ In your `pom.xml`:
```xml
<repositories>
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>io.github.null8626</groupId>
<artifactId>decancer</artifactId>
<version>3.2.3</version>
<groupId>io.github.null8626</groupId>
<artifactId>decancer</artifactId>
<version>3.2.3</version>
</dependency>
</dependencies>
```
Expand Down
2 changes: 1 addition & 1 deletion bindings/java/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(clippy::missing_safety_doc, clippy::unused_unit)]
#![allow(clippy::missing_safety_doc, clippy::unused_unit, clippy::missing_transmute_annotations)]

use jni::{
errors::Result,
Expand Down
2 changes: 2 additions & 0 deletions scripts/ci_artifacts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ void (await Promise.all(
])

await rename(join(originDir, nodeBinary), join(artifactsDir, nodeBinary))
} else if (artifact === 'java-jar') {
await rename(join(ARTIFACTS_DIR, artifact, 'decancer.jar'), join(ROOT_DIR, 'decancer.jar'))
}
})
))
Expand Down

0 comments on commit 2013291

Please sign in to comment.