- name: Install Neko using snapshot from S3 (Unix)
  if: ${{ !startsWith(env.PLATFORM, 'windows') }}
  run: |
    set -ex

    curl -sSL https://build.haxe.org/builds/neko/$PLATFORM/neko_latest.tar.gz -o $RUNNER_TEMP/neko_latest.tar.gz
    tar -xf $RUNNER_TEMP/neko_latest.tar.gz -C $RUNNER_TEMP
    NEKOPATH=`echo $RUNNER_TEMP/neko-*-*`
    sudo mkdir -p /usr/local/bin
    sudo mkdir -p /usr/local/lib/neko
    sudo ln -s $NEKOPATH/{neko,nekoc,nekoml,nekotools}  /usr/local/bin/
    sudo ln -s $NEKOPATH/libneko.*                      /usr/local/lib/
    sudo ln -s $NEKOPATH/*.ndll                         /usr/local/lib/neko/
    echo "NEKOPATH=$NEKOPATH" >> $GITHUB_ENV

- name: Install Neko using snapshot from S3 (Windows)
  if: ${{ startsWith(env.PLATFORM, 'windows') }}
  shell: pwsh
  run: |
    Invoke-WebRequest https://build.haxe.org/builds/neko/$env:PLATFORM/neko_latest.zip -OutFile $env:RUNNER_TEMP/neko_latest.zip
    Expand-Archive $env:RUNNER_TEMP/neko_latest.zip -DestinationPath $env:RUNNER_TEMP
    $NEKOPATH = Get-ChildItem $env:RUNNER_TEMP/neko-*-*
    echo "$NEKOPATH" >> $env:GITHUB_PATH
    echo "NEKOPATH=$NEKOPATH" >> $env:GITHUB_ENV

- name: Print Neko version
  run: neko -version 2>&1
