Skip to content

Commit 1be98b4

Browse files
authored
[PowerShell] better publishing workflow (#7114)
* better publishing workflow in ps * use package name in appveyor
1 parent 1ffe2a7 commit 1be98b4

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

modules/openapi-generator/src/main/resources/powershell/appveyor.mustache

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ version: 1.0.{build}
33
image:
44
- Visual Studio 2017 # PS 5.x
55
- Ubuntu # PS 6.x
6-
- macOS # PS 6.x
76
install:
87
- ps: $PSVersionTable.PSVersion
98
- ps: Install-Module Pester -Force -Scope CurrentUser
@@ -15,10 +14,17 @@ test_script:
1514
$host.SetShouldExit($Result.FailedCount)
1615
exit $Result.FailedCount
1716
}
17+
deploy_script:
1818
- ps: |
19-
if ($env:APPVEYOR_REPO_TAG -eq $true -and $env:NuGetApiKey -ne $null)
20-
{
19+
if ($env:APPVEYOR_REPO_TAG -eq $true -and $env:NuGetApiKey -ne $null -and $env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2017") {
20+
.\Build.ps1
2121
choco install NuGet.CommandLine
2222
Install-PackageProvider -Name NuGet -Force
23-
Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\ -Confirm:$False -Verbose
23+
Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\src\{{{packageName}}}\ -Confirm:$False -Verbose
24+
if ($LastExitCode -ne 0) {
25+
$host.SetShouldExit($LastExitCode)
26+
exit $LastExitCode
27+
} else {
28+
Write-Host "Published the PowerShell module."
29+
}
2430
}

samples/client/petstore/powershell/appveyor.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ version: 1.0.{build}
99
image:
1010
- Visual Studio 2017 # PS 5.x
1111
- Ubuntu # PS 6.x
12-
- macOS # PS 6.x
1312
install:
1413
- ps: $PSVersionTable.PSVersion
1514
- ps: Install-Module Pester -Force -Scope CurrentUser
@@ -21,10 +20,17 @@ test_script:
2120
$host.SetShouldExit($Result.FailedCount)
2221
exit $Result.FailedCount
2322
}
23+
deploy_script:
2424
- ps: |
25-
if ($env:APPVEYOR_REPO_TAG -eq $true -and $env:NuGetApiKey -ne $null)
26-
{
25+
if ($env:APPVEYOR_REPO_TAG -eq $true -and $env:NuGetApiKey -ne $null -and $env:APPVEYOR_BUILD_WORKER_IMAGE -eq "Visual Studio 2017") {
26+
.\Build.ps1
2727
choco install NuGet.CommandLine
2828
Install-PackageProvider -Name NuGet -Force
29-
Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\ -Confirm:$False -Verbose
29+
Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\src\PSPetstore\ -Confirm:$False -Verbose
30+
if ($LastExitCode -ne 0) {
31+
$host.SetShouldExit($LastExitCode)
32+
exit $LastExitCode
33+
} else {
34+
Write-Host "Published the PowerShell module."
35+
}
3036
}

0 commit comments

Comments
 (0)