-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpublish.ps1
43 lines (36 loc) · 1.36 KB
/
publish.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# PS Gallery publish script to be called from AppVeyor
#
$deploy=$false
$apikey=''
# Setup build environment, needed for BH* env vars
Remove-Item env:BH*
Set-BuildEnvironment
if (($env:BHBranchName -eq 'master') -and ($env:BHCommitMessage -like '*deploy*')) {
Write-Output "Publishing! On master branch and found keyword 'deploy' in commit message"
# Ensure we have a PSGallery API key
if ($null -eq $env:APIKEY) {
Write-Error '$env:APIKEY must be set before publishing'
exit 1
}
$apikey = $env:APIKEY
$deploy=$true
} else {
Write-Output "Skipping publish because not on master branch or commit message doesn't contain the word deploy"
}
# loop over each module
$modules = Get-ChildItem modules
foreach ($m in $modules) {
# Reset build environment to the current module
Remove-Item env:BH*
Set-BuildEnvironment -Path ".\modules\$($m.Name)"
# Grab the latest published version number from nuget and bump it
$version = Get-NextNugetPackageVersion -Name $env:BHProjectName
Update-Metadata -Path $env:BHPSModuleManifest -PropertyName ModuleVersion -Value $version
# Publish the new version if this is a master branch build
if ($deploy) {
Write-Output "Publishing $($m.Name) version $version"
Publish-Module -Path ".\modules\$($m.Name)" -NuGetApiKey $apikey -Verbose
} else {
Write-Output "Skipping publish $($m.Name) version $version"
}
}