name: github-query-nuget-versions
description: "Get the versions of a NuGet package."
inputs:
  url:
    description: "Url of the GitHub server repository."
    required: true
    default: ${{ github.server_url }}
  organization:
    description: "Organization to search."
    required: true
    default: ${{ github.repository_owner }}
  apiToken:
    description: "Api Token to for GitHub."
    required: true
    default: ${{ github.token }}
  prerelease:
    description: "Show prerelease packages. Values: true, false."
    required: false
    default: "false"
  name:
    description: "Name of a specific package."
    required: true
  additionalArgs:
    description: "Additional arguments to pass into curl."
    required: false
outputs:
  versions:
    description: "The versions of the specified package."
    value: ${{ steps.parse.outputs.result }}
runs:
  using: "composite"
  steps:
  - name: "Build and run query."
    id: query
    uses: act/common/github/github-query-nuget@master
    with:
      url: ${{ inputs.url }}
      organization: ${{ inputs.organization }}
      apiToken: ${{ inputs.apiToken }}
      prerelease: ${{ inputs.prerelease }}
      name: ${{ inputs.name }}
      additionalArgs: ${{ inputs.additionalArgs }}
  - name: "Parse query result."
    id: parse
    uses: act/common/yq/yq-expression@master
    with: 
      expression: .data[] | select(.id == "${{ inputs.name }}").versions[].version
      input: ${{ steps.query.outputs.query }}
