AppVeyor/AppVeyorDeploy.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
#---------------------------------#
# Header #
#---------------------------------#
Write-Host 'Running AppVeyor deploy script' -ForegroundColor Yellow

#---------------------------------#
# Update module manifest #
#---------------------------------#
Write-Host 'Creating new module manifest'

$ModuleManifestPath = Join-Path -path "$pwd" -ChildPath ("$env:ModuleName"+'.psd1')
$ModuleManifest     = Get-Content $ModuleManifestPath -Raw

Write-Host "Updating module manifest to version: $env:APPVEYOR_BUILD_VERSION"
[regex]::replace($ModuleManifest,'(ModuleVersion = )(.*)',"`$1'$env:APPVEYOR_BUILD_VERSION'") | Out-File -LiteralPath $ModuleManifestPath

#---------------------------------#
# Publish to PS Gallery #
#---------------------------------#

if ( ($env:APPVEYOR_REPO_NAME -notmatch 'PowerShellOrg') -or ($env:APPVEYOR_REPO_BRANCH -notmatch 'master') )
{
    Write-Host "Finished testing of branch: $env:APPVEYOR_REPO_BRANCH - Exiting"
    exit;
}

Write-Host "Publishing module to Powershell Gallery: "
Publish-Module -Name $env:ModuleName -NuGetApiKey $env:nugetKey

Write-Host 'Done!' -ForegroundColor Green