function New-BuildPackage { <# .SYNOPSIS Creates a new module package as compressed archive. .DESCRIPTION This function is used in build pipeline to create an uploadable module version for the Gitea release page. .PARAMETER AdditionalPath You can provide additional paths to add files or folders in published module. .INPUTS [None] No pipeline input. .OUTPUTS [None] No pipeline output. .EXAMPLE Import-Module -Name DroneHelper; New-BuildPackage #> [CmdletBinding()] [OutputType()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSUseConsistentWhitespace', '', Justification = 'Hashtable bug in ScriptAnalyzer 1.19.1' )] [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSUseShouldProcessForStateChangingFunctions', '', Justification = 'system state does not change permanent in temp build clients.' )] param ( [Parameter(Mandatory = $false)] [String[]]$AdditionalPath ) process { $Repo = Get-RepoPath $res = @() foreach ($item in $AdditionalPath) { try { $res += Resolve-Path -Path $item -ErrorAction Stop } catch { Write-Error -Message ('The given additional path does not exist! ({0})' -f $item) -ErrorAction Stop } } Merge-ModuleRoot -ErrorAction Stop $CompressParams = @{ Path = @( # psm1 file $Repo.Bin.ScriptModuleName # psd1 file $Repo.Src.Manifest.Item.FullName # Formats/ folder $Repo.Src.Formats.Path ) DestinationPath = $Repo.Bin.ArtifactPath Force = $true ErrorAction = 'Stop' Verbose = $VerbosePreference } $CompressParams.Path += $res try { Compress-Archive @CompressParams } catch { Write-FailureStateFile -StepName 'BuildPackage' throw $_.Exception.Message } } }