[PowerShell] better publishing workflow (#7114)

* better publishing workflow in ps

* use package name in appveyor
This commit is contained in:
William Cheng 2020-08-03 22:56:47 +08:00 committed by GitHub
parent 1ffe2a780a
commit 1be98b4920
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 8 deletions

View File

@ -3,7 +3,6 @@ version: 1.0.{build}
image: image:
- Visual Studio 2017 # PS 5.x - Visual Studio 2017 # PS 5.x
- Ubuntu # PS 6.x - Ubuntu # PS 6.x
- macOS # PS 6.x
install: install:
- ps: $PSVersionTable.PSVersion - ps: $PSVersionTable.PSVersion
- ps: Install-Module Pester -Force -Scope CurrentUser - ps: Install-Module Pester -Force -Scope CurrentUser
@ -15,10 +14,17 @@ test_script:
$host.SetShouldExit($Result.FailedCount) $host.SetShouldExit($Result.FailedCount)
exit $Result.FailedCount exit $Result.FailedCount
} }
deploy_script:
- ps: | - 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 choco install NuGet.CommandLine
Install-PackageProvider -Name NuGet -Force Install-PackageProvider -Name NuGet -Force
Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\ -Confirm:$False -Verbose 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."
}
} }

View File

@ -9,7 +9,6 @@ version: 1.0.{build}
image: image:
- Visual Studio 2017 # PS 5.x - Visual Studio 2017 # PS 5.x
- Ubuntu # PS 6.x - Ubuntu # PS 6.x
- macOS # PS 6.x
install: install:
- ps: $PSVersionTable.PSVersion - ps: $PSVersionTable.PSVersion
- ps: Install-Module Pester -Force -Scope CurrentUser - ps: Install-Module Pester -Force -Scope CurrentUser
@ -21,10 +20,17 @@ test_script:
$host.SetShouldExit($Result.FailedCount) $host.SetShouldExit($Result.FailedCount)
exit $Result.FailedCount exit $Result.FailedCount
} }
deploy_script:
- ps: | - 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 choco install NuGet.CommandLine
Install-PackageProvider -Name NuGet -Force Install-PackageProvider -Name NuGet -Force
Publish-Module -NuGetApiKey $env:NuGetApiKey -Path .\ -Confirm:$False -Verbose 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."
}
} }