forked from PrismLibrary/Prism
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSign-Packages.ps1
50 lines (37 loc) · 1.46 KB
/
Sign-Packages.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
$currentDirectory = split-path $MyInvocation.MyCommand.Definition
# See if we have the ClientSecret available
if([string]::IsNullOrEmpty($env:SignClientSecret)){
Write-Host "Client Secret not found, not signing packages"
return;
}
dotnet tool install --tool-path . SignClient
# Setup Variables we need to pass into the sign client tool
$appSettings = "$currentDirectory\appsettings.json"
$fileList = "$currentDirectory\filelist.txt"
if (!(Test-Path $fileList))
{
New-Item -path $currentDirectory -name filelist.txt -type "file" -value "**"
}
# Sanitize GitHub Repository Names
$repoName = $env:BUILD_REPOSITORY_NAME -replace ".*/",""
$azureAd = @{
SignClient = @{
AzureAd = @{
AADInstance = $env:SignClientAADInstance
ClientId = $env:SignClientClientId
TenantId = $env:SignClientTenantId
}
Service = @{
Url = $env:SignServiceUrl
ResourceId = $env:SignServiceResourceId
}
}
}
$azureAd | ConvertTo-Json -Compress | Out-File $appSettings
$nupkgs = Get-ChildItem $env:BUILD_ARTIFACTSTAGINGDIRECTORY\*.nupkg -recurse | Select-Object -ExpandProperty FullName
foreach ($nupkg in $nupkgs){
Write-Host "Submitting $nupkg for signing"
.\SignClient 'sign' -c $appSettings -i $nupkg -f $fileList -r $env:SignClientUser -s $env:SignClientSecret -n $repoName -d $repoName -u $env:BUILD_REPOSITORY_URI
Write-Host "Finished signing $nupkg"
}
Write-Host "Sign-package complete"