name: Install CIRCT

inputs:
  version:
    description: 'version to install'
    required: false
    default: 'firtool-1.47.0'

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

    - shell: bash
      if: steps.cache-circt.outputs.cache-hit != 'true'
      run: |
        mkdir circt
        wget -q -O - https://github.com/llvm/circt/releases/download/${{ inputs.version }}/firrtl-bin-linux-x64.tar.gz | tar -zx -C circt/ --strip-components 1

    - shell: bash
      run: echo "$(pwd)/circt/bin" >> $GITHUB_PATH
