#
# OpenAPI Petstore
# This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: "" \
# Version: 1.0.0
# Generated by OpenAPI Generator: https://openapi-generator.tech
#

version: 1.0.{build}
image:
  - Visual Studio 2019 # PWSH 7.x
  #- Visual Studio 2017 # PS 5.x, PWSH 6.x
  #- Ubuntu # PWSH 6.x
  # ref: https://www.appveyor.com/docs/windows-images-software/
install:
  - pwsh: $PSVersionTable.PSVersion
  - pwsh: Install-Module Pester -Force -Scope CurrentUser
build: off
test_script:
  - pwsh: |
      .\Build.ps1
      Import-Module -Name '.\src\PSPetstore'
      $Result = Invoke-Pester -PassThru
      if ($Result.FailedCount -gt 0) {
          $host.SetShouldExit($Result.FailedCount)
          exit $Result.FailedCount
      }
deploy_script:
  - pwsh: |
      if ($env:APPVEYOR_REPO_TAG -eq $true -and $null -ne $env:NuGetApiKey) {
          .\Build.ps1
          try {
              Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\src\PSPetstore\ -Confirm:$False -Verbose
              Write-Host "Successfully published the PowerShell module."
          } catch {
              $host.SetShouldExit($LastExitCode)
              Write-Host "Error when running Publish-Module:"
              Write-Host $_
              exit
          }
      }
