Skip to content

Commit

Permalink
Pass PSGallery API key to psake
Browse files Browse the repository at this point in the history
  • Loading branch information
devblackops committed Apr 18, 2021
1 parent eb5a7c0 commit bda2b8e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
11 changes: 8 additions & 3 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ param(

# List available build tasks
[parameter(ParameterSetName = 'Help')]
[switch]$Help
[switch]$Help,

[pscredential]$PSGalleryApiKey
)

$ErrorActionPreference = 'Stop'
Expand All @@ -31,7 +33,10 @@ if ($PSCmdlet.ParameterSetName -eq 'Help') {
Format-Table -Property Name, Description, Alias, DependsOn
} else {
Set-BuildEnvironment -Force

Invoke-psake -buildFile $psakeFile -taskList $Task -nologo
$parameters = @{}
if ($PSGalleryApiKey) {
$parameters['galleryApiKey'] = $PSGalleryApiKey
}
Invoke-psake -buildFile $psakeFile -taskList $Task -nologo -parameters $parameters
exit ( [int]( -not $psake.build_success ) )
}
7 changes: 5 additions & 2 deletions psakeFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ properties {
using namespace System.Management.Automation
using namespace System.Collections.ObjectModel
'@
$PSBPreference.Test.ImportModule = $true
$PSBPreference.Test.OutputFile = "$($PSBPreference.Build.OutDir)/testResults.xml"
$PSBPreference.Test.ImportModule = $true
$PSBPreference.Test.OutputFile = "$($PSBPreference.Build.OutDir)/testResults.xml"
if ($galleryApiKey) {
$PSBPreference.Publish.PSRepositoryApiKey = $galleryApiKey.GetNetworkCredential().password
}
}

task default -depends Test
Expand Down

0 comments on commit bda2b8e

Please sign in to comment.