CI/Publish.ps1

# Line break for readability in AppVeyor console
Write-Host -Object ''

# Publish
$script:ModuleName = Get-ProjectName
Write-PSFMessage -Level Host -Message "Starting publish region"

# Ensure pre reqs are loaded
if(!(Get-Module -Name BuildHelpers)){
  Write-Host "Loading BuildHelpers module"
}

# Set tls encryption
try {
  Write-PSFMessage -Level Host -Message "Chaging security protocol to tls1.2"
  [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
}
catch {
  Write-PSFMessage -Level Warning -Message "Failed to set security protocol"
  throw $_
  [Environment]::Exit()
}

# Publish to powershell gallery
try {
  Publish-Module -Name $ENV:BHPSModuleManifest -NuGetApiKey oy2a7w5uknwiak2zcyzaepdaxzdf6ovupioo33cbscwl74
# Publish-Module -Name $ENV:BHPSModuleManifest -NuGetApiKey oy2a7w5uknwiak2zcyzaepdaxzdf6ovupioo33cbscwl74
  Write-PSFMessage -Level Host -Message "Publishing $moduleName to PSGallery"
}
catch {
  Write-PSFMessage -Level Warning -Message "Publishing of $moduleName to PSGallery failed."
  throw $_
  [Environment]::Exit()
}