Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/java publish #178

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 68 additions & 90 deletions .github/workflows/publish-java.yaml
Original file line number Diff line number Diff line change
@@ -1,109 +1,87 @@
---
name: Publish Java Engine
name: Publish Java
on:
push:
tags:
- "java-engine-*"
workflow_dispatch:

jobs:

release-linux:
if: startsWith(github.ref, 'refs/tags/java-engine')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build Rust library for linux
run: |
cargo build --release
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 21
cache: "gradle"
distribution: "temurin"
- name: Deploy release
uses: burrunan/gradle-cache-action@v1
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassphrase: ${{ secrets.GPG_PASSPHRASE }}
with:
job-id: release-linux
arguments: publishToSonatype closeAndReleaseSonatypeStagingRepository
build-root-directory: java-engine
strategy:
matrix:
include:
# - binary: libyggdrasilffi_x86_64.so
# platform: x86_64-linux
- binary: libyggdrasilffi_arm64.so
platform: arm-linux
# - binary: libyggdrasilffi_x86_64-musl.so
# platform: x86_64-linux-musl
# - binary: libyggdrasilffi_arm64-musl.so
# platform: aarch64-linux-musl
# - binary: yggdrasilffi_x86_64.dll
# platform: x64-mingw32
# - binary: yggdrasilffi_arm64.dll
# platform: arm64-mingw32
# - binary: libyggdrasilffi_x86_64.dylib
# platform: x86_64-darwin
# - binary: libyggdrasilffi_arm64.dylib
# platform: arm64-darwin

release-windows:
if: startsWith(github.ref, 'refs/tags/java-engine')
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Build Rust Library for Windows
- name: Extract Yggdrasil Core Version
run: |
cd yggdrasilffi
cargo build --release --target x86_64-pc-windows-gnu
working-directory: ${{ github.workspace }}
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 21
cache: "gradle"
distribution: "temurin"
cd java-engine
CORE_VERSION=$(grep -E '^yggdrasilCoreVersion=' gradle.properties | cut -d'=' -f2)
echo "FFI Library Version: $CORE_VERSION"
echo "CORE_VERSION=$CORE_VERSION" >> $GITHUB_ENV

- name: Deploy release
uses: burrunan/gradle-cache-action@v1
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassphrase: ${{ secrets.GPG_PASSPHRASE }}
with:
job-id: release-linux
arguments: publishToSonatype closeAndReleaseSonatypeStagingRepository
build-root-directory: java-engine
- name: Set Platform Property for Gradle
run: |
echo "platform=${{ matrix.platform }}" >> $GITHUB_ENV

release-macos:
if: startsWith(github.ref, 'refs/tags/java-engine')
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Build Rust Library for macOS
- name: Set up Binary List
run: |
cd yggdrasilffi
cargo build --release --target x86_64-apple-darwin
working-directory: ${{ github.workspace }}
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: 21
cache: "gradle"
distribution: "temurin"
- name: Deploy release
uses: burrunan/gradle-cache-action@v1
# List of binaries we want to download
binaries=(
"libyggdrasilffi_x86_64.so"
"libyggdrasilffi_arm64.so"
"libyggdrasilffi_x86_64-musl.so"
"libyggdrasilffi_arm64-musl.so"
"yggdrasilffi_x86_64.dll"
"yggdrasilffi_arm64.dll"
"libyggdrasilffi_x86_64.dylib"
"libyggdrasilffi_arm64.dylib"
)
echo "binaries=${binaries[@]}" >> $GITHUB_ENV

- name: Download All Binaries
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TARGET_DIR="java-engine/binaries"
mkdir -p "$TARGET_DIR"

for binary in ${binaries[@]}; do
echo "Downloading $binary..."
curl -L -o "$TARGET_DIR/$binary" \
-H "Authorization: token $GITHUB_TOKEN" \
"https://github.com/${{ github.repository }}/releases/download/unleash-yggdrasil-v${CORE_VERSION}/$binary"

if [ -f "$TARGET_DIR/$binary" ]; then
echo "$binary downloaded successfully."
else
echo "Error: $binary could not be downloaded."
exit 1
fi
done

- name: Publish to Sonatype
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassphrase: ${{ secrets.GPG_PASSPHRASE }}
with:
job-id: release-linux
arguments: publishToSonatype closeAndReleaseSonatypeStagingRepository
build-root-directory: java-engine
run: |
cd java-engine
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
Loading
Loading