Wip #27
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
name: Cross-Compile | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-cross: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: | |
- x86_64-unknown-linux-gnu | |
- aarch64-unknown-linux-gnu | |
- x86_64-pc-windows-gnu | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Install cross | |
run: cargo install cross | |
- name: Cache Rust | |
uses: Swatinem/rust-cache@v2 | |
- name: Pull cross Docker image | |
run: docker pull rustembedded/cross:${{ matrix.target }} | |
- name: Cross compile | |
run: cross build --target ${{ matrix.target }} --release | |
- name: Upload so lib | |
if: matrix.target == 'x86_64-unknown-linux-gnu' || matrix.target == 'aarch64-unknown-linux-gnu' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target }}-build | |
path: target/${{ matrix.target }}/release/*.so | |
- name: Upload dll lib | |
if: matrix.target == 'x86_64-pc-windows-gnu' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.target }}-build | |
path: target/${{ matrix.target }}/release/*.dll | |
build-macos-intel: | |
runs-on: macos-12 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Cache Rust | |
uses: Swatinem/rust-cache@v2 | |
- name: Build | |
run: cargo build --target x86_64-apple-darwin --release | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: x86_64-apple-darwin-build | |
path: target/x86_64-apple-darwin/release/*.dylib | |
build-macos-arm: | |
runs-on: macos-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Cache Rust | |
uses: Swatinem/rust-cache@v2 | |
- name: Build | |
run: cargo build --target aarch64-apple-darwin --release | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: aarch64-apple-darwin-build | |
path: target/aarch64-apple-darwin/release/*.dylib | |
build-aggregated-jar: | |
runs-on: ubuntu-latest | |
needs: | |
- build-cross | |
- build-macos-intel | |
- build-macos-arm | |
steps: | |
- name: Install dependencies | |
run: sudo apt-get update | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 22 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 22 | |
- name: Gradle | |
run: chmod +x gradlew | |
- name: Create directories for artifacts | |
run: | | |
mkdir -p src/main/resources/natives/linux_64 | |
mkdir -p src/main/resources/natives/linux_arm64 | |
mkdir -p src/main/resources/natives/windows_64 | |
mkdir -p src/main/resources/natives/osx_64 | |
mkdir -p src/main/resources/natives/osx_arm64 | |
- name: Download Linux artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: x86_64-unknown-linux-gnu-build | |
path: src/main/resources/natives/linux_64 | |
- name: Download AArch64 Linux artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: aarch64-unknown-linux-gnu-build | |
path: src/main/resources/natives/linux_arm64 | |
- name: Download Windows artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: x86_64-pc-windows-gnu-build | |
path: src/main/resources/natives/windows_64 | |
- name: Download macOS Intel artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: x86_64-apple-darwin-build | |
path: src/main/resources/natives/osx_64 | |
- name: Download macOS ARM64 artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: aarch64-apple-darwin-build | |
path: src/main/resources/natives/osx_arm64 | |
- name: Build JAR | |
run: ./gradlew jar | |
- name: Upload JAR artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: surrealdb-jni | |
path: build/libs/surrealdb-jni-0.2-SNAPSHOT.jar | |
- name: Linux Integration Test | |
run: ./gradlew -i integrationTest | |
integration-tests: | |
runs-on: windows-latest | |
needs: | |
- build-aggregated-jar | |
steps: | |
- name: Set up JDK 22 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 22 | |
- name: Gradle | |
run: chmod +x gradlew | |
- name: Create directory build/libs | |
run: mkdir -p build/libs | |
- name: Download lib | |
uses: actions/download-artifact@v4 | |
with: | |
name: surrealdb-jni | |
path: build/libs | |
- name: Windows Integration Test | |
run: ./gradlew -i integrationTest | |
mac-intel-integration-test: | |
runs-on: macos-12 | |
needs: | |
- build-aggregated-jar | |
steps: | |
- name: Set up JDK 22 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 22 | |
- name: Gradle | |
run: chmod +x gradlew | |
- name: Create directory build/libs | |
run: mkdir -p build/libs | |
- name: Download lib | |
uses: actions/download-artifact@v4 | |
with: | |
name: surrealdb-jni | |
path: build/libs | |
- name: Mac Integration Test | |
run: ./gradlew -i integrationTest | |
mac-arm-integration-test: | |
runs-on: macos-latest | |
needs: | |
- build-aggregated-jar | |
steps: | |
- name: Set up JDK 22 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 22 | |
- name: Gradle | |
run: chmod +x gradlew | |
- name: Create directory build/libs | |
run: mkdir -p build/libs | |
- name: Download lib | |
uses: actions/download-artifact@v4 | |
with: | |
name: surrealdb-jni | |
path: build/libs | |
- name: Mac Integration Test | |
run: ./gradlew -i integrationTest |