name: Install Espresso

inputs:
  version:
    description: 'version to install'
    required: false
    default: '2.4'

runs:
  using: composite
  steps:
    - id: cache-espresso
      uses: actions/cache@v3
      with:
        path: /usr/local/bin/espresso
        key: espresso-${{ runner.os }}-${{ inputs.version }}

    - shell: bash
      if: steps.cache-espresso.outputs.cache-hit != 'true'
      run: |
        cd /tmp
        wget -q https://github.com/chipsalliance/espresso/releases/download/v${{ inputs.version }}/x86_64-linux-gnu-espresso
        chmod +x x86_64-linux-gnu-espresso
        sudo mv x86_64-linux-gnu-espresso /usr/local/bin/espresso
        espresso || true
