name: Install Vulkan SDK
description: Downloads and installs Vulkan SDK.
inputs:
  vulkan-version:
    description: 'Vulkan SDK release version (e.g. 1.2.198.1).'
    default: '1.2.198.1'
    required: false
runs:
  using: "composite"
  steps:
    - name: Install Vulkan SDK
      shell: bash
      run: |
        export VULKAN_SDK_VER=${{ inputs.vulkan-version }}
        echo VULKAN_SDK_VER=$VULKAN_SDK_VER >> $GITHUB_ENV
        echo "Downloading Vulkan SDK version $VULKAN_SDK_VER"
        case `uname -s` in
          Linux)
            export VULKAN_SDK_ROOT=`pwd`/../VulkanSDK
            wget "https://sdk.lunarg.com/sdk/download/$VULKAN_SDK_VER/linux/vulkan-sdk.tar.gz" --no-verbose -O vulkan-sdk.tar.gz
            mkdir $VULKAN_SDK_ROOT
            tar -xf vulkan-sdk.tar.gz -C $VULKAN_SDK_ROOT
            export VULKAN_SDK=$VULKAN_SDK_ROOT/$VULKAN_SDK_VER/x86_64
            ;;
          Darwin)
            export VULKAN_SDK_ROOT=`pwd`/../VulkanSDK
            curl -LO "https://sdk.lunarg.com/sdk/download/$VULKAN_SDK_VER/mac/vulkan-sdk.dmg"
            hdiutil attach vulkan-sdk.dmg -mountpoint /Volumes/vulkan-sdk
            sudo "/Volumes/vulkan-sdk/InstallVulkan.app/Contents/MacOS/InstallVulkan" --root $VULKAN_SDK_ROOT --accept-licenses --default-answer --confirm-command install
            export VULKAN_SDK=$VULKAN_SDK_ROOT/macOS
            ;;
          *) # Windows
            curl -L -o vulkan-sdk.exe https://sdk.lunarg.com/sdk/download/$VULKAN_SDK_VER/windows/VulkanSDK-$VULKAN_SDK_VER-Installer.exe
            ./vulkan-sdk.exe --root "C:\VulkanSDK"  --accept-licenses --default-answer --confirm-command install
            export VULKAN_SDK="C:\VulkanSDK"
            ;;
        esac
        echo VULKAN_SDK=$VULKAN_SDK >> $GITHUB_ENV
        echo "Vulkan SDK installed to $VULKAN_SDK"
