name: nuget-compare-version
description: "Download the desired .nupkg file and compare it to an existing .nupkg file."
inputs:
  lhs:
    description: "Path to the existing .nupkg file."
    required: true
  name:
    description: "Name of the .nupkg file."
    required: true
  version:
    description: "Version of the .nupkg file."
    required: false
    default: ""
  prerelease:
    description: "Install prerelease packages. Values: true, false."
    required: false
    default: "${{ github.event_name == 'pull_request' }}"
  url:
    description: "Url of the NuGet repository."
    required: true
    default: ${{ github.server_url }}/_registry/nuget/${{ github.repository_owner }}/index.json
  username:
    description: "Username for the nuget repository to search."
    required: true
    default: ${{ github.actor }}
  password:
    description: "Password or ApiKey of the nuget repository to search."
    required: true
    default: ${{ github.token }}
  tmpDir:
    description: "Temporary directory. Default: _tmp"
    required: true
    default: _tmp
outputs:
  success:
    description: "Whether or not the .nupkg files match."
    value: ${{ steps.compare.outputs.success }}
runs:
  using: "composite"
  steps:
  - name: "Make temporary folder if we are using .nupkg only."
    id: mktmp
    uses: act/common/utils/mktemp@master
    with:
      tmpDir: ${{ inputs.tmpDir }}
      outputType: dir
  - name: "Get the desired version of the package."
    id: install
    uses: act/common/nuget/nuget-install@master
    with:
      name: ${{ inputs.name }}
      version: ${{ inputs.version }}
      prerelease: ${{ inputs.prerelease }}
      url: ${{ inputs.url }}
      username: ${{ inputs.username }}
      password: ${{ inputs.password }}
      outputDirectory: ${{ steps.mktmp.outputs.tmp }}
      nupkgOnly: true
      directDownload: true
      cleanTmp: false
  - name: "Compare the two .nupkg files."
    id: compare
    uses: act/common/utils/compare-nupkg@master
    with:
      lhs: ${{ inputs.lhs }}
      rhs: ${{ steps.install.outputs.nupkg }}
  - name: "Remove temporary files."
    run: rm -rf "${{ inputs.tmpDir }}"
    shell: bash
