mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Package signing (#5463)
* add template xml for package signing * Add script to generate package signing XML * remove uploading artifact, it always fails. * Allow the XML to be updated to be specified
This commit is contained in:
@@ -451,7 +451,6 @@ function New-PSSignedBuildZip
|
||||
$name = split-path -Path $BuildPath -Leaf
|
||||
$zipLocationPath = Join-Path -Path $DestinationFolder -ChildPath "$name-signed.zip"
|
||||
Compress-Archive -Path $BuildPath\* -DestinationPath $zipLocationPath
|
||||
Write-Host "##vso[artifact.upload containerfolder=results;artifactname=$name]$zipLocationPath"
|
||||
if ($VstsVariableName)
|
||||
{
|
||||
# set VSTS variable with path to package files
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string] $Path,
|
||||
[string[]] $AuthenticodeDualFiles,
|
||||
[string[]] $AuthenticodeFiles
|
||||
)
|
||||
|
||||
if ((!$AuthenticodeDualFiles -or $AuthenticodeDualFiles.Count -eq 0) -and (!$AuthenticodeFiles -or $AuthenticodeFiles.Count -eq 0))
|
||||
{
|
||||
throw "At least one file must be specified"
|
||||
}
|
||||
|
||||
function New-Attribute
|
||||
{
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$Name,
|
||||
[Parameter(Mandatory)]
|
||||
[object]$Value,
|
||||
[Parameter(Mandatory)]
|
||||
[System.Xml.XmlElement]$Element
|
||||
)
|
||||
|
||||
$attribute = $signingXml.CreateAttribute($Name)
|
||||
$attribute.Value = $value
|
||||
$null = $fileElement.Attributes.Append($attribute)
|
||||
}
|
||||
|
||||
function New-FileElement
|
||||
{
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$File,
|
||||
[Parameter(Mandatory)]
|
||||
[string]$SignType,
|
||||
[Parameter(Mandatory)]
|
||||
[System.Xml.XmlDocument]$XmlDoc,
|
||||
[Parameter(Mandatory)]
|
||||
[System.Xml.XmlElement]$Job
|
||||
)
|
||||
|
||||
if(Test-Path -Path $file)
|
||||
{
|
||||
$name = Split-Path -Leaf -Path $File
|
||||
$null = $fileElement = $XmlDoc.CreateElement("file")
|
||||
New-Attribute -Name 'src' -value $file -Element $fileElement
|
||||
New-Attribute -Name 'signType' -value $SignType -Element $fileElement
|
||||
New-Attribute -Name 'dest' -value "__OUTPATHROOT__\$name" -Element $fileElement
|
||||
$null = $job.AppendChild($fileElement)
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Warning -Message "Skipping $SignType; $File because it does not exist"
|
||||
}
|
||||
}
|
||||
|
||||
[xml]$signingXml = get-content (Join-Path -Path $PSScriptRoot -ChildPath 'packagesigning.xml')
|
||||
$job = $signingXml.SignConfigXML.job
|
||||
|
||||
foreach($file in $AuthenticodeDualFiles)
|
||||
{
|
||||
New-FileElement -File $file -SignType 'AuthenticodeDual' -XmlDoc $signingXml -Job $job
|
||||
}
|
||||
|
||||
foreach($file in $AuthenticodeFiles)
|
||||
{
|
||||
New-FileElement -File $file -SignType 'Authenticode' -XmlDoc $signingXml -Job $job
|
||||
}
|
||||
|
||||
$signingXml.Save($path)
|
||||
$updateScriptPath = Join-Path -Path $PSScriptRoot -ChildPath 'updateSigning.ps1'
|
||||
& $updateScriptPath -SigningXmlPath $path
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!-- template used by generatePackageSigning.ps1 -->
|
||||
<SignConfigXML>
|
||||
<job platform="" configuration="" dest="__OUTPATHROOT__\signed" jobname="PowerShell Packages" approvers="vigarg;gstolt">
|
||||
</job>
|
||||
</SignConfigXML>
|
||||
@@ -1,7 +1,9 @@
|
||||
param(
|
||||
[string] $SigningXmlPath = (Join-Path -Path $PSScriptRoot -ChildPath 'signing.xml')
|
||||
)
|
||||
# Script for use in VSTS to update signing.xml
|
||||
|
||||
# Parse the signing xml
|
||||
$signingXmlPath = Join-Path -Path $PSScriptRoot -ChildPath 'signing.xml'
|
||||
$signingXml = [xml](Get-Content $signingXmlPath)
|
||||
|
||||
# Get any variables to updating 'signType' in the XML
|
||||
|
||||
Reference in New Issue
Block a user