on: [workflow_call]

name: libextism

runs:
  using: composite
  steps:
    - name: Checkout sources
      uses: actions/checkout@v3
    - name: Install Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
        override: true
    - name: Cache Rust environment
      uses: Swatinem/rust-cache@v1
    - name: Cache libextism
      id: cache-libextism
      uses: actions/cache@v3
      with:
        path: target/**
        key: ${{ runner.os }}-libextism-${{ hashFiles('runtime/**') }}-${{ hashFiles('manifest/**') }}-${{ hashFiles('libextism/**') }}
    - name: Build
      if: steps.cache-libextism.outputs.cache-hit != 'true'
      shell: bash
      run: cargo build --release -p libextism
    - name: Install extism shared library
      shell: bash
      run: |
        sudo make install
