name: nuget-pack
description: "Pack a .nuspec file into a .nupkg."
inputs:
  nuspec:
    description: "The .nuspec file or configuration to pack."
    required: true
  version:
    description: "Version of the .nupkg file."
    required: true
  outputDirectory:
    description: "Directory for the output file."
    required: true
  additionalArgs:
    description: "Additional arguments to use when packing the .nuspec file."
    required: false
runs:
  using: "composite"
  steps:
  - name: "Make temporary file of nuspec."
    id: tmp
    uses: act/common/utils/mktemp@master
    with:
      input: ${{ inputs.nuspec }}
      tmpDir: .
      additionalArgs: --suffix=.nuspec
  - name: "Create Output Directory"
    run: |
      OUTPUT_DIR="${{ inputs.outputDirectory }}"
      mkdir "$OUTPUT_DIR" -p
    shell: bash
  - name: "Build the .nupkg file."
    uses: act/common/nuget/nuget@master
    with:
      command: pack "${{ steps.tmp.outputs.tmp }}" -OutputDirectory "${{ inputs.outputDirectory }}" -Version "${{ inputs.version }}" ${{ inputs.additionalArgs }}
  - name: "Remove temporary files."
    run: rm -rf "${{ steps.tmp.outputs.tmp }}"
    shell: bash