alice-physics 2.2.0

Deterministic physics engine: 128-bit fixed-point rigid bodies with bit-exact, replayable results, typed observation and rollback for search and planning, plus FEM, CFD and 3D-print analysis modules
Documentation
name: Release

on:
  push:
    tags:
      - 'v*'

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    name: Build (${{ matrix.lib_dir }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: macos-latest
            target: aarch64-apple-darwin
            lib_name: libalice_physics.dylib
            static_lib_name: libalice_physics.a
            lib_dir: macOS
          # macos-*-intel labels are GitHub's Intel-native macOS runners.
          # Regular macos-14 / macos-15 / macos-26 are Apple Silicon (ARM) —
          # building x86_64-apple-darwin from ARM requires either a cross
          # toolchain or native Intel hardware. `macos-15-intel` keeps this
          # build natively linked without cross-compilation setup.
          - os: macos-15-intel
            target: x86_64-apple-darwin
            lib_name: libalice_physics.dylib
            static_lib_name: libalice_physics.a
            lib_dir: macOS-Intel
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            lib_name: alice_physics.dll
            static_lib_name: alice_physics.lib
            lib_dir: Win64
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            lib_name: libalice_physics.so
            static_lib_name: libalice_physics.a
            lib_dir: Linux

    steps:
      - uses: actions/checkout@v5

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - uses: Swatinem/rust-cache@v2

      - name: Build release (dynamic library)
        shell: bash
        run: |
          cargo rustc --release --features "ffi" --target ${{ matrix.target }} \
            --crate-type cdylib

      - name: Build release (static library)
        shell: bash
        run: |
          cargo rustc --release --features "ffi" --target ${{ matrix.target }} \
            --crate-type staticlib

      - name: Package UE5 Plugin
        shell: bash
        run: |
          PLUGIN_DIR="AlicePhysics"
          mkdir -p "$PLUGIN_DIR/ThirdParty/AlicePhysics/lib/${{ matrix.lib_dir }}"
          mkdir -p "$PLUGIN_DIR/ThirdParty/AlicePhysics/include"
          cp unreal-plugin/AlicePhysics.uplugin "$PLUGIN_DIR/"
          cp -r unreal-plugin/Source "$PLUGIN_DIR/"
          cp -r unreal-plugin/Resources "$PLUGIN_DIR/" 2>/dev/null || true
          cp unreal-plugin/README.md "$PLUGIN_DIR/"
          cp include/alice_physics.h "$PLUGIN_DIR/ThirdParty/AlicePhysics/include/"
          cp "target/${{ matrix.target }}/release/${{ matrix.lib_name }}" \
             "$PLUGIN_DIR/ThirdParty/AlicePhysics/lib/${{ matrix.lib_dir }}/"

      - name: Create UE5 ZIP (Unix)
        if: runner.os != 'Windows'
        run: zip -r "AlicePhysics-UE5-${{ matrix.lib_dir }}.zip" AlicePhysics/

      - name: Create UE5 ZIP (Windows)
        if: runner.os == 'Windows'
        run: 7z a "AlicePhysics-UE5-${{ matrix.lib_dir }}.zip" AlicePhysics/

      - name: Package Unity Plugin
        shell: bash
        run: |
          UNITY_DIR="AlicePhysics-Unity"
          mkdir -p "$UNITY_DIR/Plugins/${{ matrix.lib_dir }}"
          cp bindings/AlicePhysics.cs "$UNITY_DIR/"
          cp include/alice_physics.h "$UNITY_DIR/"
          cp "target/${{ matrix.target }}/release/${{ matrix.lib_name }}" \
             "$UNITY_DIR/Plugins/${{ matrix.lib_dir }}/"

      - name: Create Unity ZIP (Unix)
        if: runner.os != 'Windows'
        run: zip -r "AlicePhysics-Unity-${{ matrix.lib_dir }}.zip" AlicePhysics-Unity/

      - name: Create Unity ZIP (Windows)
        if: runner.os == 'Windows'
        run: 7z a "AlicePhysics-Unity-${{ matrix.lib_dir }}.zip" AlicePhysics-Unity/

      - name: Package Static Library
        shell: bash
        run: |
          STATIC_DIR="AlicePhysics-StaticLib-${{ matrix.lib_dir }}"
          mkdir -p "$STATIC_DIR/lib"
          mkdir -p "$STATIC_DIR/include"
          cp include/alice_physics.h "$STATIC_DIR/include/"
          cp "target/${{ matrix.target }}/release/${{ matrix.static_lib_name }}" \
             "$STATIC_DIR/lib/"

      - name: Create Static Library ZIP (Unix)
        if: runner.os != 'Windows'
        run: zip -r "AlicePhysics-StaticLib-${{ matrix.lib_dir }}.zip" "AlicePhysics-StaticLib-${{ matrix.lib_dir }}/"

      - name: Create Static Library ZIP (Windows)
        if: runner.os == 'Windows'
        run: 7z a "AlicePhysics-StaticLib-${{ matrix.lib_dir }}.zip" "AlicePhysics-StaticLib-${{ matrix.lib_dir }}/"

      - name: Upload artifacts
        uses: actions/upload-artifact@v6
        with:
          name: release-${{ matrix.lib_dir }}
          path: |
            AlicePhysics-UE5-${{ matrix.lib_dir }}.zip
            AlicePhysics-Unity-${{ matrix.lib_dir }}.zip
            AlicePhysics-StaticLib-${{ matrix.lib_dir }}.zip

  python-wheel:
    name: Python Wheel (${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
          - os: macos-latest
            target: aarch64-apple-darwin
          - os: windows-latest
            target: x86_64-pc-windows-msvc
    steps:
      - uses: actions/checkout@v5

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - uses: actions/setup-python@v6
        with:
          python-version: '3.12'

      - name: Install maturin
        run: pip install maturin

      - name: Build wheel
        run: maturin build --release --features python --out dist/

      # the wheel itself is installed and exercised, not only built: a wheel that
      # builds but fails to import or returns wrong values must not be released
      - name: Install the wheel and run the binding tests
        shell: bash
        run: |
          python -m pip install numpy dist/*.whl
          python python/tests/test_binding.py

      - name: Upload wheel
        uses: actions/upload-artifact@v6
        with:
          name: wheel-${{ matrix.os }}
          path: dist/*.whl

  release:
    name: Create Release
    needs: [build, python-wheel]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5

      - name: Download all artifacts
        uses: actions/download-artifact@v7
        with:
          path: artifacts

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v3
        with:
          files: |
            artifacts/**/*.zip
            artifacts/**/*.whl
          generate_release_notes: true