feat: add wasm and other bindings #469
This file contains hidden or 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: JVM CI | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| tags: ['*'] | |
| paths: | |
| - 'crates/jvm-bindings/**' | |
| - 'crates/jvm-bindings-gpu/**' | |
| - 'crates/core_cpu/**' | |
| - 'crates/core_gpu/**' | |
| - 'crates/core/**' | |
| - '.github/workflows/jvm-ci.yaml' | |
| - 'Cargo.toml' | |
| pull_request: | |
| paths: | |
| - 'crates/jvm-bindings/**' | |
| - 'crates/jvm-bindings-gpu/**' | |
| - 'crates/core_cpu/**' | |
| - 'crates/core_gpu/**' | |
| - 'crates/core/**' | |
| - '.github/workflows/jvm-ci.yaml' | |
| - 'Cargo.toml' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| VULKAN_VERSION: 1.4.304.1 | |
| jobs: | |
| cpu-build: | |
| name: "cpu-build — ${{ matrix.target }}" | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: | |
| - x86_64-unknown-linux-gnu | |
| - aarch64-unknown-linux-gnu | |
| - x86_64-apple-darwin | |
| - aarch64-apple-darwin | |
| - x86_64-pc-windows-msvc | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| runner: ubuntu-latest | |
| lib: libmodern_colorthief.so | |
| shell: bash | |
| - target: aarch64-unknown-linux-gnu | |
| runner: ubuntu-latest | |
| lib: libmodern_colorthief.so | |
| shell: bash | |
| - target: x86_64-apple-darwin | |
| runner: macos-15-intel | |
| lib: libmodern_colorthief.dylib | |
| shell: bash | |
| - target: aarch64-apple-darwin | |
| runner: macos-latest | |
| lib: libmodern_colorthief.dylib | |
| shell: bash | |
| - target: x86_64-pc-windows-msvc | |
| runner: windows-latest | |
| lib: modern_colorthief.dll | |
| shell: pwsh | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: '26' | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache cargo registry | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cargo/registry | |
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Install cross (aarch64-linux) | |
| if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }} | |
| run: cargo install cross | |
| - name: Build JVM native library | |
| if: ${{ matrix.target != 'aarch64-unknown-linux-gnu' }} | |
| run: cargo build --release --target ${{ matrix.target }} -p modern-colorthief-jvm | |
| env: | |
| MACOSX_DEPLOYMENT_TARGET: 10.12 | |
| - name: Build JVM native library (cross-compile) | |
| if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }} | |
| run: cross build --release --target ${{ matrix.target }} -p modern-colorthief-jvm | |
| - name: Run Rust core unit tests | |
| run: cargo test -p modern-colorthief-core -p modern-colorthief-core-cpu | |
| - name: Upload native library | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: "native-lib-cpu-${{ matrix.target }}" | |
| path: target/${{ matrix.target }}/release/${{ matrix.lib }} | |
| retention-days: 7 | |
| cpu-junit: | |
| name: "cpu-junit — ${{ matrix.os }}" | |
| needs: [cpu-build] | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-15-intel, windows-latest] | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| lib: libmodern_colorthief.so | |
| shell: bash | |
| - os: macos-15-intel | |
| target: x86_64-apple-darwin | |
| lib: libmodern_colorthief.dylib | |
| shell: bash | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| lib: modern_colorthief.dll | |
| shell: pwsh | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: '26' | |
| - name: Download native library | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: native-lib-cpu-${{ matrix.target }} | |
| path: crates/jvm-bindings/tests/native | |
| - name: Verify native library | |
| shell: bash | |
| run: test -f crates/jvm-bindings/tests/native/${{ matrix.lib }} | |
| - uses: gradle/actions/setup-gradle@v6 | |
| with: | |
| gradle-version: '9.5.1' | |
| - name: Generate Gradle wrapper | |
| working-directory: crates/jvm-bindings/tests | |
| run: gradle wrapper | |
| - name: Run JUnit tests | |
| working-directory: crates/jvm-bindings/tests | |
| run: ./gradlew test --info | |
| gpu-build: | |
| name: "gpu-build — ${{ matrix.target }}" | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: | |
| - x86_64-unknown-linux-gnu | |
| - x86_64-apple-darwin | |
| - x86_64-pc-windows-msvc | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| runner: ubuntu-latest | |
| lib: libmodern_colorthief_gpu.so | |
| shell: bash | |
| - target: x86_64-apple-darwin | |
| runner: macos-15-intel | |
| lib: libmodern_colorthief_gpu.dylib | |
| shell: bash | |
| - target: x86_64-pc-windows-msvc | |
| runner: windows-latest | |
| lib: modern_colorthief_gpu.dll | |
| shell: pwsh | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install Vulkan runtime (Linux) | |
| if: ${{ contains(matrix.target, '-linux-gnu') }} | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libvulkan1 mesa-vulkan-drivers vulkan-tools | |
| - name: Install Vulkan SDK + SwiftShader (Windows) | |
| if: ${{ contains(matrix.target, '-windows-') }} | |
| uses: jakoch/install-vulkan-sdk-action@v1 | |
| with: | |
| vulkan_version: ${{ env.VULKAN_VERSION }} | |
| install_swiftshader: true | |
| cache: true | |
| github_token: ${{ github.token }} | |
| - name: Setup SwiftShader (Windows) | |
| if: ${{ contains(matrix.target, '-windows-') }} | |
| shell: pwsh | |
| run: | | |
| $sdkBin = "$env:VULKAN_SDK\Bin" | |
| if (Test-Path $sdkBin) { | |
| Add-Content -Path $env:GITHUB_PATH -Value $sdkBin | |
| } | |
| $icdJson = "C:\SwiftShader\vk_swiftshader_icd.json" | |
| if (Test-Path $icdJson) { | |
| Add-Content -Path $env:GITHUB_ENV -Value "VK_ICD_FILENAMES=$icdJson" | |
| } else { | |
| $fallbackIcd = "$env:VULKAN_SDK\Bin\vk_swiftshader_icd.json" | |
| if (Test-Path $fallbackIcd) { | |
| Add-Content -Path $env:GITHUB_ENV -Value "VK_ICD_FILENAMES=$fallbackIcd" | |
| } | |
| } | |
| - name: Install Vulkan SDK + SwiftShader (macOS) | |
| if: ${{ contains(matrix.target, '-apple-darwin') }} | |
| uses: jakoch/install-vulkan-sdk-action@v1 | |
| with: | |
| vulkan_version: ${{ env.VULKAN_VERSION }} | |
| install_lavapipe: true | |
| install_swiftshader: true | |
| cache: true | |
| github_token: ${{ github.token }} | |
| - name: Setup Vulkan environment (macOS) | |
| if: ${{ contains(matrix.target, '-apple-darwin') }} | |
| shell: bash | |
| run: bash .github/scripts/setup_vulkan_macos.sh | |
| - uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cargo/registry | |
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Build GPU native library | |
| run: cargo build --release --target ${{ matrix.target }} -p modern-colorthief-jvm-gpu | |
| - name: Verify shared library | |
| shell: bash | |
| run: test -f target/${{ matrix.target }}/release/${{ matrix.lib }} | |
| - name: Upload GPU native library | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: "native-lib-gpu-${{ matrix.target }}" | |
| path: target/${{ matrix.target }}/release/${{ matrix.lib }} | |
| retention-days: 7 | |
| gpu-rust-test: | |
| name: "gpu-rust-test — ${{ matrix.target }}" | |
| needs: [gpu-build] | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: | |
| - x86_64-unknown-linux-gnu | |
| - x86_64-apple-darwin | |
| - x86_64-pc-windows-msvc | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| runner: ubuntu-latest | |
| - target: x86_64-apple-darwin | |
| runner: macos-15-intel | |
| - target: x86_64-pc-windows-msvc | |
| runner: windows-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.cargo/registry | |
| key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Install Vulkan runtime (Linux) | |
| if: ${{ contains(matrix.target, '-linux-gnu') }} | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libvulkan1 mesa-vulkan-drivers vulkan-tools | |
| - name: Install Vulkan SDK + SwiftShader (Windows) | |
| if: ${{ contains(matrix.target, '-windows-') }} | |
| uses: jakoch/install-vulkan-sdk-action@v1 | |
| with: | |
| vulkan_version: ${{ env.VULKAN_VERSION }} | |
| install_swiftshader: true | |
| cache: true | |
| github_token: ${{ github.token }} | |
| - name: Setup SwiftShader (Windows) | |
| if: ${{ contains(matrix.target, '-windows-') }} | |
| shell: pwsh | |
| run: | | |
| $sdkBin = "$env:VULKAN_SDK\Bin" | |
| if (Test-Path $sdkBin) { | |
| Add-Content -Path $env:GITHUB_PATH -Value $sdkBin | |
| } | |
| $icdJson = "C:\SwiftShader\vk_swiftshader_icd.json" | |
| if (Test-Path $icdJson) { | |
| Add-Content -Path $env:GITHUB_ENV -Value "VK_ICD_FILENAMES=$icdJson" | |
| } else { | |
| $fallbackIcd = "$env:VULKAN_SDK\Bin\vk_swiftshader_icd.json" | |
| if (Test-Path $fallbackIcd) { | |
| Add-Content -Path $env:GITHUB_ENV -Value "VK_ICD_FILENAMES=$fallbackIcd" | |
| } | |
| } | |
| - name: Install Vulkan SDK + SwiftShader (macOS) | |
| if: ${{ contains(matrix.target, '-apple-darwin') }} | |
| uses: jakoch/install-vulkan-sdk-action@v1 | |
| with: | |
| vulkan_version: ${{ env.VULKAN_VERSION }} | |
| install_lavapipe: true | |
| install_swiftshader: true | |
| cache: true | |
| github_token: ${{ github.token }} | |
| - name: Setup Vulkan environment (macOS) | |
| if: ${{ contains(matrix.target, '-apple-darwin') }} | |
| shell: bash | |
| run: bash .github/scripts/setup_vulkan_macos.sh | |
| - name: Run Rust GPU unit tests | |
| run: cargo test -p modern-colorthief-core -p modern-colorthief-core-cpu -p modern-colorthief-core-gpu --target ${{ matrix.target }} | |
| gpu-junit: | |
| name: "gpu-junit — ${{ matrix.os }}" | |
| needs: [gpu-build] | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-15-intel, windows-latest] | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| lib: libmodern_colorthief_gpu.so | |
| shell: bash | |
| - os: macos-15-intel | |
| target: x86_64-apple-darwin | |
| lib: libmodern_colorthief_gpu.dylib | |
| shell: bash | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| lib: modern_colorthief_gpu.dll | |
| shell: pwsh | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: '26' | |
| - name: Install Vulkan runtime (Linux) | |
| if: ${{ matrix.os == 'ubuntu-latest' }} | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libvulkan1 mesa-vulkan-drivers vulkan-tools | |
| - name: Install Vulkan SDK + SwiftShader (Windows) | |
| if: ${{ matrix.os == 'windows-latest' }} | |
| uses: jakoch/install-vulkan-sdk-action@v1 | |
| with: | |
| vulkan_version: ${{ env.VULKAN_VERSION }} | |
| install_swiftshader: true | |
| cache: true | |
| github_token: ${{ github.token }} | |
| - name: Setup SwiftShader (Windows) | |
| if: ${{ matrix.os == 'windows-latest' }} | |
| shell: pwsh | |
| run: | | |
| $sdkBin = "$env:VULKAN_SDK\Bin" | |
| if (Test-Path $sdkBin) { | |
| Add-Content -Path $env:GITHUB_PATH -Value $sdkBin | |
| } | |
| $icdJson = "C:\SwiftShader\vk_swiftshader_icd.json" | |
| if (Test-Path $icdJson) { | |
| Add-Content -Path $env:GITHUB_ENV -Value "VK_ICD_FILENAMES=$icdJson" | |
| } else { | |
| $fallbackIcd = "$env:VULKAN_SDK\Bin\vk_swiftshader_icd.json" | |
| if (Test-Path $fallbackIcd) { | |
| Add-Content -Path $env:GITHUB_ENV -Value "VK_ICD_FILENAMES=$fallbackIcd" | |
| } | |
| } | |
| - name: Install Vulkan SDK + SwiftShader (macOS) | |
| if: ${{ startsWith(matrix.os, 'macos') }} | |
| uses: jakoch/install-vulkan-sdk-action@v1 | |
| with: | |
| vulkan_version: ${{ env.VULKAN_VERSION }} | |
| install_lavapipe: true | |
| install_swiftshader: true | |
| cache: true | |
| github_token: ${{ github.token }} | |
| - name: Setup Vulkan environment (macOS) | |
| if: ${{ startsWith(matrix.os, 'macos') }} | |
| shell: bash | |
| run: bash .github/scripts/setup_vulkan_macos.sh | |
| - name: Download GPU native library | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: native-lib-gpu-${{ matrix.target }} | |
| path: crates/jvm-bindings-gpu/tests/native | |
| - name: Verify native library | |
| shell: bash | |
| run: test -f crates/jvm-bindings-gpu/tests/native/${{ matrix.lib }} | |
| - uses: gradle/actions/setup-gradle@v6 | |
| with: | |
| gradle-version: '9.5.1' | |
| - name: Generate Gradle wrapper | |
| working-directory: crates/jvm-bindings-gpu/tests | |
| run: gradle wrapper | |
| - name: Run GPU JUnit tests | |
| working-directory: crates/jvm-bindings-gpu/tests | |
| run: ./gradlew test --info | |
| android-check: | |
| name: Android check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android | |
| - run: cargo check --target aarch64-linux-android -p modern-colorthief-core -p modern-colorthief-core-cpu | |
| - run: cargo check --target armv7-linux-androideabi -p modern-colorthief-core -p modern-colorthief-core-cpu | |
| - run: cargo check --target i686-linux-android -p modern-colorthief-core -p modern-colorthief-core-cpu | |
| - run: cargo check --target x86_64-linux-android -p modern-colorthief-core -p modern-colorthief-core-cpu | |
| - run: cargo check --target aarch64-linux-android -p modern-colorthief-jvm | |
| - run: cargo check --target x86_64-linux-android -p modern-colorthief-jvm | |
| publish-cpu: | |
| name: Publish CPU to Maven Central | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: [cpu-junit, cpu-build] | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: '26' | |
| - name: Download all CPU native libraries | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: native-lib-cpu-* | |
| path: crates/jvm-bindings/tests/native | |
| - name: Stage CPU native libraries | |
| run: | | |
| find crates/jvm-bindings/tests/native -type f \( -name '*.so' -o -name '*.dll' -o -name '*.dylib' \) -exec mv {} crates/jvm-bindings/tests/native/ \; | |
| find crates/jvm-bindings/tests/native -mindepth 1 -type d -delete | |
| ls -la crates/jvm-bindings/tests/native/ | |
| - name: Import GPG signing key | |
| run: | | |
| echo "${{ secrets.GPG_SECRET_KEY }}" | base64 --decode | gpg --batch --import | |
| shell: bash | |
| - uses: gradle/actions/setup-gradle@v6 | |
| with: | |
| gradle-version: '9.5.1' | |
| - name: Generate Gradle wrapper | |
| working-directory: crates/jvm-bindings/tests | |
| run: gradle wrapper | |
| - name: Publish to Maven Central | |
| working-directory: crates/jvm-bindings/tests | |
| run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository --info | |
| env: | |
| ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} | |
| ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} | |
| ORG_GRADLE_PROJECT_sonatypeToken: ${{ secrets.SONATYPE_TOKEN }} | |
| ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SECRET_KEY }} | |
| ORG_GRADLE_PROJECT_signingInMemoryPassword: ${{ secrets.GPG_PASSPHRASE }} | |
| publish-gpu: | |
| name: Publish GPU to Maven Central | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: [gpu-junit, gpu-build] | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: '26' | |
| - name: Download all GPU native libraries | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: native-lib-gpu-* | |
| path: crates/jvm-bindings-gpu/tests/native | |
| - name: Stage GPU native libraries | |
| run: | | |
| find crates/jvm-bindings-gpu/tests/native -type f \( -name '*.so' -o -name '*.dll' -o -name '*.dylib' \) -exec mv {} crates/jvm-bindings-gpu/tests/native/ \; | |
| find crates/jvm-bindings-gpu/tests/native -mindepth 1 -type d -delete | |
| ls -la crates/jvm-bindings-gpu/tests/native/ | |
| - name: Import GPG signing key | |
| run: | | |
| echo "${{ secrets.GPG_SECRET_KEY }}" | base64 --decode | gpg --batch --import | |
| shell: bash | |
| - uses: gradle/actions/setup-gradle@v6 | |
| with: | |
| gradle-version: '9.5.1' | |
| - name: Generate Gradle wrapper | |
| working-directory: crates/jvm-bindings-gpu/tests | |
| run: gradle wrapper | |
| - name: Publish GPU to Maven Central | |
| working-directory: crates/jvm-bindings-gpu/tests | |
| run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository --info | |
| env: | |
| ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }} | |
| ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }} | |
| ORG_GRADLE_PROJECT_sonatypeToken: ${{ secrets.SONATYPE_TOKEN }} | |
| ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SECRET_KEY }} | |
| ORG_GRADLE_PROJECT_signingInMemoryPassword: ${{ secrets.GPG_PASSPHRASE }} |