name: Setup OSS CAD Suite

inputs:
  version:
    description: 'version to install'
    required: false
    default: '2021-11-09'

runs:
  using: composite
  steps:
    - id: cache-oss-cad-suite
      uses: actions/cache@v3
      with:
        path: oss-cad-suite
        key: oss-cad-suite-${{ runner.os }}-${{ inputs.version }}

    - shell: bash
      if: steps.cache-oss-cad-suite.outputs.cache-hit != 'true'
      run: |
        VERSION=${{ inputs.version }}
        ARTIFACT=oss-cad-suite-linux-x64-$(echo $VERSION | tr -d '-')
        wget -q -O - https://github.com/YosysHQ/oss-cad-suite-build/releases/download/${VERSION}/${ARTIFACT}.tgz | tar -zx

    # Add the CAD Suite to the PATH
    - shell: bash
      run: echo "$(pwd)/oss-cad-suite/bin" >> $GITHUB_PATH

