From 67c920579c3aca43c90ce6870a2101db19964cc5 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 3 Aug 2020 15:06:54 +0800 Subject: [PATCH 1/2] better publishing workflow in ps --- .../src/main/resources/powershell/appveyor.mustache | 13 +++++++++---- samples/client/petstore/powershell/appveyor.yml | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/powershell/appveyor.mustache b/modules/openapi-generator/src/main/resources/powershell/appveyor.mustache index f337f619ba0c..ffb394ea2527 100644 --- a/modules/openapi-generator/src/main/resources/powershell/appveyor.mustache +++ b/modules/openapi-generator/src/main/resources/powershell/appveyor.mustache @@ -3,7 +3,6 @@ version: 1.0.{build} image: - Visual Studio 2017 # PS 5.x - Ubuntu # PS 6.x - - macOS # PS 6.x install: - ps: $PSVersionTable.PSVersion - ps: Install-Module Pester -Force -Scope CurrentUser @@ -15,10 +14,16 @@ test_script: $host.SetShouldExit($Result.FailedCount) exit $Result.FailedCount } +deploy_script: - ps: | - if ($env:APPVEYOR_REPO_TAG -eq $true -and $env:NuGetApiKey -ne $null) - { + if ($env:APPVEYOR_REPO_TAG -eq $true -and $env:NuGetApiKey -ne $null -and $env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2017") { + .\Build.ps1 choco install NuGet.CommandLine Install-PackageProvider -Name NuGet -Force - Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\ -Confirm:$False -Verbose + Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\src\PSOpenAPITools\ -Confirm:$False -Verbose + if($LastExitCode -ne 0) { + $host.SetShouldExit($LastExitCode ) + } else { + Write-Host "Published the PowerShell module." + } } diff --git a/samples/client/petstore/powershell/appveyor.yml b/samples/client/petstore/powershell/appveyor.yml index ec43839e3e3f..272598d97516 100644 --- a/samples/client/petstore/powershell/appveyor.yml +++ b/samples/client/petstore/powershell/appveyor.yml @@ -9,7 +9,6 @@ version: 1.0.{build} image: - Visual Studio 2017 # PS 5.x - Ubuntu # PS 6.x - - macOS # PS 6.x install: - ps: $PSVersionTable.PSVersion - ps: Install-Module Pester -Force -Scope CurrentUser @@ -21,10 +20,16 @@ test_script: $host.SetShouldExit($Result.FailedCount) exit $Result.FailedCount } +deploy_script: - ps: | - if ($env:APPVEYOR_REPO_TAG -eq $true -and $env:NuGetApiKey -ne $null) - { + if ($env:APPVEYOR_REPO_TAG -eq $true -and $env:NuGetApiKey -ne $null -and $env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2017") { + .\Build.ps1 choco install NuGet.CommandLine Install-PackageProvider -Name NuGet -Force - Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\ -Confirm:$False -Verbose + Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\src\PSOpenAPITools\ -Confirm:$False -Verbose + if($LastExitCode -ne 0) { + $host.SetShouldExit($LastExitCode ) + } else { + Write-Host "Published the PowerShell module." + } } From 5c4bea2cd3b1b9c31f9d0cb041c2a27932d04cdc Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 3 Aug 2020 20:11:03 +0800 Subject: [PATCH 2/2] use package name in appveyor --- .../src/main/resources/powershell/appveyor.mustache | 7 ++++--- samples/client/petstore/powershell/appveyor.yml | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/powershell/appveyor.mustache b/modules/openapi-generator/src/main/resources/powershell/appveyor.mustache index ffb394ea2527..0f70eb14ecfd 100644 --- a/modules/openapi-generator/src/main/resources/powershell/appveyor.mustache +++ b/modules/openapi-generator/src/main/resources/powershell/appveyor.mustache @@ -20,9 +20,10 @@ deploy_script: .\Build.ps1 choco install NuGet.CommandLine Install-PackageProvider -Name NuGet -Force - Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\src\PSOpenAPITools\ -Confirm:$False -Verbose - if($LastExitCode -ne 0) { - $host.SetShouldExit($LastExitCode ) + Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\src\{{{packageName}}}\ -Confirm:$False -Verbose + if ($LastExitCode -ne 0) { + $host.SetShouldExit($LastExitCode) + exit $LastExitCode } else { Write-Host "Published the PowerShell module." } diff --git a/samples/client/petstore/powershell/appveyor.yml b/samples/client/petstore/powershell/appveyor.yml index 272598d97516..1d3959705c84 100644 --- a/samples/client/petstore/powershell/appveyor.yml +++ b/samples/client/petstore/powershell/appveyor.yml @@ -26,9 +26,10 @@ deploy_script: .\Build.ps1 choco install NuGet.CommandLine Install-PackageProvider -Name NuGet -Force - Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\src\PSOpenAPITools\ -Confirm:$False -Verbose - if($LastExitCode -ne 0) { - $host.SetShouldExit($LastExitCode ) + Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\src\PSPetstore\ -Confirm:$False -Verbose + if ($LastExitCode -ne 0) { + $host.SetShouldExit($LastExitCode) + exit $LastExitCode } else { Write-Host "Published the PowerShell module." }