OCram85/DroneHelper
OCram85
/
DroneHelper
Archived
1
0
Fork 0
This repository has been archived on 2023-10-10. You can view files and clone it, but cannot push or open issues or pull requests.
DroneHelper/src/Build/New-BuildPackage.ps1

75 lines
2.2 KiB
PowerShell

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
}
}
}