Public/Publish-PsmModule.ps1

function Publish-PsmModule {
  <#
    .Synopsis
      Publish-PsmModule does this... Short description
    .DESCRIPTION
      Publish-PsmModule does this, that, and the other... Long description
    .EXAMPLE
      Publish-PsmModule "DEV" .\Here\this\path\file.txt
  #>
      
  [CmdletBinding(SupportsShouldProcess=$true)]  
  param ()  

  BEGIN{
    Write-Verbose "Starting Publish-PsmModule..."
    Confirm-IsInitializedModulePath
    $packageXml = Import-CliXml .\module-psd1.xml
    $config = Import-Clixml .\.env
  }#begin

  PROCESS{
    if ($psCmdlet.ShouldProcess(<# on target --> #>$packageXml.RootModule, <# What if: Performing operation --> #>"Publishing to configured repository")) { 
      try {
        Write-Verbose "Publishing module by path: .\$($packageXml.RootModule)"
        Publish-Module -Path ".\$($packageXml.RootModule)" -NuGetApiKey $config.apikey -Force -Verbose
      }
      catch {
        Write-Verbose "
 
Failed to publish module by path...
  $($_.Exception.ItemName) : $($_.Exception.Message)
 
"

      }
    }
  }#process
  END{
    Write-Verbose "Finished Publish-PsmModule..."
  }#end
}