chore: Update Windows zip archive creation (#14015)

This commit is contained in:
Joshua Powers 2023-09-29 04:14:36 -06:00 committed by GitHub
parent d07701f35f
commit 0deb3d5047
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -11,16 +11,20 @@ $certBytes = [Convert]::FromBase64String($certText)
$CertPath = $finalFileName
$Cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($CertPath, $CertPass)
# Update the version of Compress-Archive to support zipping correctly.
Install-Module Microsoft.PowerShell.Archive -MinimumVersion 1.2.3.0 -Repository PSGallery -Force
Import-Module Microsoft.PowerShell.Archive
# Go through the artifacts directory and sign the 'windows' artifacts.
$artifactDirectory = "./build/dist"
$extractDirectory = $artifactDirectory + "\" + "extracted"
foreach ($file in get-ChildItem $artifactDirectory | where {$_.name -like "*windows*"} | select name)
$extractDirectory = $artifactDirectory + "/" + "extracted"
foreach ($file in get-ChildItem $artifactDirectory | where {$_.name -like "*windows*"} | select name)
{
$artifact = $artifactDirectory + "\" + $file.Name
$artifact = $artifactDirectory + "/" + $file.Name
Expand-Archive -LiteralPath $artifact -DestinationPath $extractDirectory -Force
$subDirectoryPath = $extractDirectory + "\" + (Get-ChildItem -Path $extractDirectory | Select-Object -First 1).Name
$telegrafExePath = $subDirectoryPath + "\" + "telegraf.exe"
$subDirectoryPath = $extractDirectory + "/" + (Get-ChildItem -Path $extractDirectory | Select-Object -First 1).Name
$telegrafExePath = $subDirectoryPath + "/" + "telegraf.exe"
Set-AuthenticodeSignature -Certificate $Cert -FilePath $telegrafExePath -TimestampServer http://timestamp.digicert.com
Compress-Archive -Path $subDirectoryPath -DestinationPath $artifact -Force
Remove-Item $extractDirectory -Force -Recurse