Skip to content

Fix: Resolve syntax error in build.gradle.kts from internal edit #47

Fix: Resolve syntax error in build.gradle.kts from internal edit

Fix: Resolve syntax error in build.gradle.kts from internal edit #47

Workflow file for this run

name: Build Rust Bridge
on:
push:
branches: [ "main" ]
tags: [ "v*" ]
pull_request:
branches: [ "main" ]
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Java
id: setup-java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Set up Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.10'
# 1. Common Environment Setup (Explicit Linking)
- name: Configure Common Environment
shell: bash
run: |
echo "JAVA_HOME=${{ steps.setup-java.outputs.path }}" >> $GITHUB_ENV
echo "PYO3_PYTHON=${{ steps.setup-python.outputs.python-path }}" >> $GITHUB_ENV
# 2. OS-Specific Handling
# Linux: Install python3-dev
- name: Install Dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y python3-dev
# Windows: Setup MSVC
- name: Setup MSVC (Windows)
if: matrix.os == 'windows-latest'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
# Rust Setup
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
# 3. Log Debugging & Build Prep
- name: Debug Environment
shell: bash
run: |
echo "=== Environment Variables ==="
env
echo "=== File System (Recursive) ==="
echo "=== File System (Recursive) ==="
ls -R
# Windows Linker Check (cmd-friendly check not needed here, will do in build step)
if [ "${{ matrix.os }}" == "windows-latest" ]; then
echo "Skipping bash-based link check on Windows"
fi
# macOS Explicit JAVA_HOME injection check (User requirement)
if [ "${{ matrix.os }}" == "macos-latest" ]; then
echo "Injecting MacOS specific JAVA_HOME..."
export JAVA_HOME=$(/usr/libexec/java_home)
echo "JAVA_HOME is now: $JAVA_HOME"
fi
# 4. Dependency Isolation & Build
# 4. Dependency Isolation & Build
# Windows Build (CMD ensures correct env inheritance from msvc-dev-cmd)
- name: Build Release (Windows)
if: matrix.os == 'windows-latest'
working-directory: ./rust-bridge
shell: cmd
run: |
echo === Windows Linker Debug ===
where link
echo Building in %CD%
cargo build --release
# Linux/macOS Build (Bash)
- name: Build Release (Unix)
if: matrix.os != 'windows-latest'
working-directory: ./rust-bridge
shell: bash
run: |
# Re-export variables just in case shell isolation dropped them
if [ "${{ matrix.os }}" == "macos-latest" ]; then
export JAVA_HOME=$(/usr/libexec/java_home)
fi
echo "Building in $(pwd)..."
cargo build --release
- name: Upload Artifact (Windows)
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: jpyrust-windows
path: rust-bridge/target/release/jpyrust.dll
- name: Upload Artifact (Linux)
if: matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@v4
with:
name: jpyrust-linux
path: rust-bridge/target/release/libjpyrust.so
- name: Upload Artifact (macOS)
if: matrix.os == 'macos-latest'
uses: actions/upload-artifact@v4
with:
name: jpyrust-macos
path: rust-bridge/target/release/libjpyrust.dylib
# ====================================
# Release Job: Create GitHub Release
# ====================================
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Display Artifacts
run: ls -R artifacts/
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
artifacts/jpyrust-windows/jpyrust.dll
artifacts/jpyrust-linux/libjpyrust.so
artifacts/jpyrust-macos/libjpyrust.dylib
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}