Move to ESRP signing for Windows files (#13988)

Co-authored-by: Aditya Patwardhan <adityap@microsoft.com>
This commit is contained in:
Travis Plunk 2020-11-05 13:28:40 -08:00 committed by GitHub
parent d6727dcf1b
commit 05f274898d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 154 additions and 703 deletions

View file

@ -1,463 +0,0 @@
jobs:
- job: BuildJob
displayName: Build
condition: succeeded()
pool:
name: Package ES Standard Build
strategy:
matrix:
Build (x64,release):
BuildConfiguration: release
BuildPlatform: any cpu
Architecture: x64
Build (x86,release):
BuildConfiguration: release
BuildPlatform: any cpu
Architecture: x86
Build (arm,release):
BuildConfiguration: release
BuildPlatform: any cpu
Architecture: arm
Build (arm64,release):
BuildConfiguration: release
BuildPlatform: any cpu
Architecture: arm64
Build (fxdependent,release):
BuildConfiguration: release
BuildPlatform: any cpu
Architecture: fxdependent
steps:
- checkout: self
clean: true
- task: PkgESSetupBuild@10
displayName: 'Initialize build'
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
useDfs: false
productName: PowerShellCore
branchVersion: true
disableWorkspace: true
disableBuildTools: true
disableNugetPack: true
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))
- powershell: |
tools/releaseBuild/setReleaseTag.ps1 -ReleaseTag $(ReleaseTag)
displayName: 'Set ReleaseTag Variable'
- powershell: |
Write-Verbose -Verbose "$(Architecture)"
if ('$(Architecture)' -eq 'fxdependent' -and '$(ReleaseTag)' -match '6.0.*')
{
$vstsCommandString = "vso[task.setvariable variable=SkipFxDependent]true"
}
else
{
$vstsCommandString = "vso[task.setvariable variable=SkipFxDependent]false"
}
Write-Verbose -Message "$vstsCommandString " -Verbose
Write-Host -Object "##$vstsCommandString"
displayName: 'Skip FxDependent for PS v6.0.*'
- powershell: |
Import-Module $(Build.SourcesDirectory)/build.psm1 -Force
New-NugetConfigFile -NugetFeedUrl $(AzDevOpsFeed) -UserName $(AzDevOpsFeedUserName) -ClearTextPAT $(AzDevOpsFeedPAT) -FeedName AzDevOpsFeed -Destination $(Build.SourcesDirectory)/src/Modules
if(-not (Test-Path "$(Build.SourcesDirectory)/src/Modules/nuget.config"))
{
throw "nuget.config is not created"
}
displayName: 'Add nuget.config for AzDevOps feed for PSGallery modules '
condition: ne(Variables['SkipFxDependent'], 'true')
- powershell: |
$version = $env:ReleaseTag.Substring(1)
$vstsCommandString = "vso[task.setvariable variable=Version]$version"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: 'Set Version Varibale'
condition: and(succeeded(), ne(variables['SkipFxDependent'], 'true'))
- powershell: |
docker container prune --force
docker container ls --all --format '{{ json .ID }}' | ConvertFrom-Json | ForEach-Object {docker container rm --force --volumes $_}
displayName: 'remove all containers [Port to PSRelease]'
continueOnError: true
condition: and(succeeded(), ne(variables['SkipFxDependent'], 'true'))
- powershell: |
docker image ls --format '{{ json .}}'|ConvertFrom-Json| ForEach-Object {
if($_.tag -eq '<none>')
{
$formatString = 'yyyy-MM-dd HH:mm:ss zz00'
$createdAtString = $_.CreatedAt.substring(0,$_.CreatedAt.Length -4)
$createdAt = [DateTime]::ParseExact($createdAtString, $formatString,[System.Globalization.CultureInfo]::InvariantCulture)
if($createdAt -lt (Get-Date).adddays(-1))
{
docker image rm $_.ID
}
}
}
exit 0
displayName: 'remove old images [Port to PSRelease]'
continueOnError: true
condition: and(succeeded(), ne(variables['SkipFxDependent'], 'true'))
- powershell: |
Write-verbose "--docker info---" -verbose
docker info
Write-verbose "--docker image ls---" -verbose
docker image ls
Write-verbose "--docker container ls --all---" -verbose
docker container ls --all
Write-verbose "--git branch ---" -verbose
git branch
exit 0
displayName: 'Get Environment'
condition: and(succeeded(), ne(variables['SkipFxDependent'], 'true'))
- powershell: |
tools/releaseBuild/vstsbuild.ps1 -ReleaseTag $(ReleaseTag) -Name win-$(Architecture)-symbols
displayName: 'Build Windows Universal - $(Architecture) Symbols zip'
continueOnError: true
condition: and(succeeded(), ne(variables['SkipFxDependent'], 'true'))
- powershell: |
if ("$env:Architecture" -eq 'fxdependent')
{
$(Build.SourcesDirectory)\tools\releaseBuild\updateSigning.ps1 -SkipPwshExe
}
else
{
$(Build.SourcesDirectory)\tools\releaseBuild\updateSigning.ps1
}
displayName: 'Update Signing Xml'
condition: and(succeeded(), ne(variables['SkipFxDependent'], 'true'))
- powershell: |
$vstsCommandString = "vso[task.setvariable variable=Symbols]${env:Symbols_$(Architecture)}"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: 'Get Symbols path [Update build.json]'
condition: and(succeeded(), ne(variables['SkipFxDependent'], 'true'))
- task: PkgESCodeSign@10
displayName: 'CodeSign $(Architecture)'
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
signConfigXml: '$(Build.SourcesDirectory)\tools\releaseBuild\signing.xml'
inPathRoot: '$(Symbols)'
outPathRoot: '$(Symbols)\signed'
binVersion: $(SigingVersion)
binVersionOverride: $(SigningVersionOverride)
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'), ne(variables['SkipFxDependent'], 'true'))
- powershell: |
New-Item -ItemType Directory -Path $(Symbols)\signed -Force
displayName: 'Create empty signed folder'
condition: and(succeeded(), ne(variables['Build.Reason'], 'Manual'), ne(variables['SkipFxDependent'], 'true'))
- powershell: |
tools/releaseBuild/vstsbuild.ps1 -ReleaseTag $(ReleaseTag) -Name win-$(Architecture)-package -BuildPath $(Symbols) -SignedFilesPath $(Symbols)\signed
displayName: 'Build Windows Universal - $(Architecture) Package'
continueOnError: true
condition: and(succeeded(), ne(variables['SkipFxDependent'], 'true'))
- job: ComponentRegistrationJob
displayName: Component Registration
dependsOn: BuildJob
condition: succeeded()
pool:
name: Package ES Standard Build
strategy:
matrix:
release-anycpu:
BuildConfiguration: release
BuildPlatform: any cpu
steps:
- powershell: |
./tools/releaseBuild/setReleaseTag.ps1 -ReleaseTag $(ReleaseTag)
displayName: 'Set ReleaseTag Variable'
- powershell: |
$version = $env:ReleaseTag.Substring(1)
$vstsCommandString = "vso[task.setvariable variable=Version]$version"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: 'Set Version Variable'
- powershell: |
docker container prune --force
docker container ls --all --format '{{ json .ID }}' | ConvertFrom-Json | ForEach-Object {docker container rm --force --volumes $_}
displayName: 'Remove all containers'
continueOnError: true
- powershell: |
docker image ls --format '{{ json .}}'|ConvertFrom-Json| ForEach-Object {
if($_.tag -eq '<none>')
{
$formatString = 'yyyy-MM-dd HH:mm:ss zz00'
$createdAtString = $_.CreatedAt.substring(0,$_.CreatedAt.Length -4)
$createdAt = [DateTime]::ParseExact($createdAtString, $formatString,[System.Globalization.CultureInfo]::InvariantCulture)
if($createdAt -lt (Get-Date).adddays(-1))
{
docker image rm $_.ID
}
}
}
exit 0
displayName: 'Remove old images'
continueOnError: true
- powershell: |
Write-verbose "--docker info---" -verbose
docker info
Write-verbose "--docker image ls---" -verbose
docker image ls
Write-verbose "--docker container ls --all---" -verbose
docker container ls --all
Write-verbose "--git branch ---" -verbose
git branch
exit 0
displayName: 'Get Environment'
- powershell: |
./tools/releaseBuild/vstsbuild.ps1 -ReleaseTag $(ReleaseTag) -Name win-x64-component-registration
displayName: 'Build Windows Universal - Component Registration'
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
displayName: 'Component Detection'
inputs:
sourceScanPath: '$(componentregistration)'
snapshotForceEnabled: true
- job: PackageSigningJob
displayName: Package signing
dependsOn: BuildJob
condition: succeeded()
pool:
name: Package ES Standard Build
strategy:
matrix:
release-anycpu:
BuildConfiguration: release
BuildPlatform: any cpu
steps:
- powershell: |
tools/releaseBuild/setReleaseTag.ps1 -ReleaseTag $(ReleaseTag)
displayName: 'Set ReleaseTag Variable'
continueOnError: true
- powershell: |
$version = $env:ReleaseTag.Substring(1)
$vstsCommandString = "vso[task.setvariable variable=Version]$version"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
$azureVersion = $env:ReleaseTag.ToLowerInvariant() -replace '\.', '-'
$vstsCommandString = "vso[task.setvariable variable=AzureVersion]$azureVersion"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: 'Set Version Variable'
continueOnError: true
- task: DownloadBuildArtifacts@0
displayName: 'Download artifacts'
inputs:
downloadType: specific
continueOnError: true
- powershell: |
dir "$(System.ArtifactsDirectory)\*" -Recurse
displayName: 'dir artifacts directory'
continueOnError: true
- powershell: |
Expand-Archive -Path "$(System.ArtifactsDirectory)\results\PowerShell-$(Version)-symbols-win-x86.zip" -Destination "$(Build.StagingDirectory)\symbols\x86"
displayName: 'Expand symbols zip - x86'
continueOnError: true
- powershell: |
Expand-Archive -Path "$(System.ArtifactsDirectory)\results\PowerShell-$(Version)-symbols-win-x64.zip" -Destination "$(Build.StagingDirectory)\symbols\x64"
displayName: 'Expand symbols zip - x64'
continueOnError: true
- powershell: |
Expand-Archive -Path "$(System.ArtifactsDirectory)\results\PowerShell-$(Version)-symbols-win-fxdependent.zip" -Destination "$(Build.StagingDirectory)\symbols\fxdependent"
displayName: 'Expand symbols zip - fxdependent'
continueOnError: true
- powershell: |
tools/releaseBuild/generatePackgeSigning.ps1 -AuthenticodeFiles "$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-x64.msi","$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-x86.msi" -path "$(System.ArtifactsDirectory)\package.xml"
displayName: 'Generate Package Signing Xml'
- powershell: |
Get-Content "$(System.ArtifactsDirectory)\package.xml"
displayName: 'print signing xml'
continueOnError: true
- task: PkgESCodeSign@10
displayName: 'CodeSign $(System.ArtifactsDirectory)\package.xml'
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
signConfigXml: '$(System.ArtifactsDirectory)\package.xml'
outPathRoot: '$(Build.StagingDirectory)\signedPackages'
binVersion: $(SigingVersion)
binVersionOverride: $(SigningVersionOverride)
continueOnError: true
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))
- powershell: |
$packagePath = "$(Build.StagingDirectory)\signedPackages\PowerShell-$(Version)-win-x64.msi"
if(Test-Path -Path $packagePath)
{
Write-Host "##vso[artifact.upload containerfolder=signedResults;artifactname=signedResults]$packagePath"
}
displayName: '[Create script] upload signed msi - x64'
continueOnError: true
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))
- task: AzureFileCopy@4
displayName: 'upload signed msi to Azure - x64'
inputs:
SourcePath: '$(Build.StagingDirectory)\signedPackages\PowerShell-$(Version)-win-x64.msi'
azureSubscription: '$(AzureFileCopySubscription)'
Destination: AzureBlob
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
continueOnError: true
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))
- powershell: |
$packagePath = "$(Build.StagingDirectory)\signedPackages\PowerShell-$(Version)-win-x86.msi"
if(Test-Path -Path $packagePath)
{
Write-Host "##vso[artifact.upload containerfolder=signedResults;artifactname=signedResults]$packagePath"
}
displayName: '[create script] upload signed msi - x86'
continueOnError: true
- task: AzureFileCopy@4
displayName: 'upload signed msi to Azure - x86'
inputs:
SourcePath: '$(Build.StagingDirectory)\signedPackages\PowerShell-$(Version)-win-x86.msi'
azureSubscription: '$(AzureFileCopySubscription)'
Destination: AzureBlob
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
continueOnError: true
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))
- powershell: |
$packagePath = "$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-x64.zip"
if(Test-Path -Path $packagePath)
{
Write-Host "##vso[artifact.upload containerfolder=signedResults;artifactname=signedResults]$packagePath"
}
displayName: '[Create script] upload signed zip - x64'
continueOnError: true
- task: AzureFileCopy@4
displayName: 'upload signed zip to Azure - x64'
inputs:
SourcePath: '$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-x64.zip'
azureSubscription: '$(AzureFileCopySubscription)'
Destination: AzureBlob
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
continueOnError: true
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))
- powershell: |
$packagePath = "$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-x86.zip"
if(Test-Path -Path $packagePath)
{
Write-Host "##vso[artifact.upload containerfolder=signedResults;artifactname=signedResults]$packagePath"
}
displayName: '[create script] upload signed zip - x86'
continueOnError: true
- task: AzureFileCopy@4
displayName: 'upload signed zip to Azure - x86'
inputs:
SourcePath: '$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-x86.zip'
azureSubscription: '$(AzureFileCopySubscription)'
Destination: AzureBlob
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
continueOnError: true
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))
- powershell: |
$packagePath = "$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-arm32.zip"
if(Test-Path -Path $packagePath)
{
Write-Host "##vso[artifact.upload containerfolder=signedResults;artifactname=signedResults]$packagePath"
}
displayName: '[create script] upload signed zip - arm'
continueOnError: true
- task: AzureFileCopy@4
displayName: 'upload signed zip to Azure - arm'
inputs:
SourcePath: '$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-arm32.zip'
azureSubscription: '$(AzureFileCopySubscription)'
Destination: AzureBlob
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
continueOnError: true
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))
- powershell: |
$packagePath = "$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-arm64.zip"
if(Test-Path -Path $packagePath)
{
Write-Host "##vso[artifact.upload containerfolder=signedResults;artifactname=signedResults]$packagePath"
}
displayName: '[create script] upload signed zip - arm64'
continueOnError: true
- task: AzureFileCopy@4
displayName: 'upload signed zip to Azure - arm64'
inputs:
SourcePath: '$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-arm64.zip'
azureSubscription: '$(AzureFileCopySubscription)'
Destination: AzureBlob
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
continueOnError: true
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))
- powershell: |
$packagePath = "$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-fxdependent.zip"
if(Test-Path -Path $packagePath)
{
Write-Host "##vso[artifact.upload containerfolder=signedResults;artifactname=signedResults]$packagePath"
}
displayName: '[create script] upload signed zip - fxdependent'
continueOnError: true
- task: AzureFileCopy@4
displayName: 'upload signed zip to Azure - fxdependent'
inputs:
SourcePath: '$(System.ArtifactsDirectory)\signed\PowerShell-$(Version)-win-fxdependent.zip'
azureSubscription: '$(AzureFileCopySubscription)'
Destination: AzureBlob
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
continueOnError: true
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))

View file

@ -10,9 +10,18 @@ pr:
- master
- release*
resources:
repositories:
- repository: ComplianceRepo
type: github
endpoint: ComplianceGHRepo
name: PowerShell/compliance
variables:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
POWERSHELL_TELEMETRY_OPTOUT: 1
- name: DOTNET_CLI_TELEMETRY_OPTOUT
value: 1
- name: POWERSHELL_TELEMETRY_OPTOUT
value: 1
stages:
- stage: prep
@ -146,6 +155,10 @@ stages:
pool:
vmImage: 'windows-latest'
steps:
- checkout: self
clean: true
fetchDepth: 1
- template: templates/SetVersionVariables.yml
parameters:
ReleaseTagVar: $(ReleaseTagVar)

View file

@ -4,9 +4,29 @@ parameters:
CreateJson: 'no'
steps:
- powershell: |
$path = "./build.psm1"
if(Test-Path -Path $path)
{
$vstsCommandString = "vso[task.setvariable variable=repoRoot]."
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"
}
else{
$path = "./PowerShell/build.psm1"
if(Test-Path -Path $path)
{
$vstsCommandString = "vso[task.setvariable variable=repoRoot]./PowerShell"
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"
}
}
displayName: 'Set repo Root'
- powershell: |
$createJson = ("${{ parameters.ReleaseTagVarName }}" -ne "no")
$releaseTag = tools/releaseBuild/setReleaseTag.ps1 -ReleaseTag ${{ parameters.ReleaseTagVar }} -Variable "${{ parameters.ReleaseTagVarName }}" -CreateJson:$createJson
$releaseTag = & "$env:REPOROOT/tools/releaseBuild/setReleaseTag.ps1" -ReleaseTag ${{ parameters.ReleaseTagVar }} -Variable "${{ parameters.ReleaseTagVarName }}" -CreateJson:$createJson
$version = $releaseTag.Substring(1)
$vstsCommandString = "vso[task.setvariable variable=Version]$version"
Write-Host ("sending " + $vstsCommandString)

View file

@ -8,6 +8,8 @@ jobs:
steps:
- checkout: self
clean: true
fetchDepth: 1
- template: SetVersionVariables.yml
parameters:
ReleaseTagVar: $(ReleaseTagVar)

View file

@ -0,0 +1,16 @@
steps:
- powershell: |
$dirSeparatorChar = [system.io.path]::DirectorySeparatorChar
$nativePath = "${dirSeparatorChar}PowerShell"
Write-Host "##vso[task.setvariable variable=PowerShellRoot]$nativePath"
if ((Test-Path "$nativePath")) {
Remove-Item -Path "$nativePath" -Force -Recurse -Verbose -ErrorAction ignore
}
else {
Write-Verbose -Verbose -Message "No cleanup required."
}
git clone --quiet $env:REPOROOT $nativePath
displayName: Clone PowerShell Repo to /PowerShell
errorActionPreference: silentlycontinue

View file

@ -17,6 +17,7 @@ jobs:
steps:
- checkout: self
clean: true
fetchDepth: 1
- template: SetVersionVariables.yml
parameters:

View file

@ -19,6 +19,7 @@ jobs:
# displayName: '<display name of task>'
- checkout: self
clean: true
fetchDepth: 1
- template: SetVersionVariables.yml
parameters:

View file

@ -15,6 +15,7 @@ jobs:
steps:
- checkout: self
clean: true
fetchDepth: 1
- template: shouldSign.yml

View file

@ -24,11 +24,6 @@ jobs:
sudo chown $env:USER /PowerShell
displayName: 'Create /PowerShell'
- pwsh: |
Write-Host "##vso[task.setvariable variable=PowerShellRoot]/PowerShell"
git clone $env:BUILD_REPOSITORY_LOCALPATH /PowerShell
displayName: Clone PowerShell Repo to /PowerShell
- template: shouldSign.yml
#- task: <task type name>@<version>
@ -39,6 +34,7 @@ jobs:
parameters:
ReleaseTagVar: $(ReleaseTagVar)
- template: cloneToOfficialPath.yml
- task: DownloadBuildArtifacts@0
displayName: Download macosBinResults

View file

@ -15,6 +15,7 @@ jobs:
steps:
- checkout: self
clean: true
fetchDepth: 1
- template: shouldSign.yml

View file

@ -29,10 +29,7 @@ jobs:
sudo chown $env:USER /PowerShell
displayName: 'Create /PowerShell'
- pwsh: |
Write-Host "##vso[task.setvariable variable=PowerShellRoot]/PowerShell"
git clone $env:BUILD_REPOSITORY_LOCALPATH /PowerShell
displayName: Clone PowerShell Repo to /PowerShell
- template: cloneToOfficialPath.yml
- pwsh: |
tools/releaseBuild/macOS/PowerShellPackageVsts.ps1 -location $(PowerShellRoot) -BootStrap

View file

@ -14,6 +14,7 @@ jobs:
steps:
- checkout: self
clean: true
fetchDepth: 1
- download: releasePipeline
artifact: finalResults

View file

@ -11,6 +11,7 @@ jobs:
steps:
- checkout: self
clean: true
fetchDepth: 1
- download: releasePipeline
artifact: finalResults

View file

@ -8,6 +8,7 @@ jobs:
steps:
- checkout: self
clean: true
fetchDepth: 1
- download: releasePipeline
artifact: finalResults

View file

@ -9,6 +9,7 @@ jobs:
steps:
- checkout: self
clean: true
fetchDepth: 1
- template: ./SetVersionVariables.yml
parameters:

View file

@ -1,125 +0,0 @@
parameters:
BuildConfiguration: release
BuildPlatform: any cpu
Architecture: x64
jobs:
- job: build_windows_${{ parameters.Architecture }}
displayName: Build Windows - ${{ parameters.Architecture }}
condition: succeeded()
pool:
name: Package ES Standard Build
variables:
BuildConfiguration: ${{ parameters.BuildConfiguration }}
BuildPlatform: ${{ parameters.BuildPlatform }}
Architecture: ${{ parameters.Architecture }}
steps:
- checkout: self
clean: true
- template: shouldSign.yml
- template: SetVersionVariables.yml
parameters:
ReleaseTagVar: $(ReleaseTagVar)
- task: PkgESSetupBuild@10
displayName: 'Initialize build'
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
useDfs: false
productName: PowerShellCore
branchVersion: true
disableWorkspace: true
disableBuildTools: true
disableNugetPack: true
condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true'))
- template: insert-nuget-config-azfeed.yml
- powershell: |
docker container prune --force
docker container ls --all --format '{{ json .ID }}' | ConvertFrom-Json | ForEach-Object {docker container rm --force --volumes $_}
displayName: 'Remove all containers [Port to PSRelease]'
# Cleanup is not critical it passes every time it runs
continueOnError: true
- powershell: |
docker image ls --format '{{ json .}}'|ConvertFrom-Json| ForEach-Object {
if($_.tag -eq '<none>')
{
$formatString = 'yyyy-MM-dd HH:mm:ss zz00'
$createdAtString = $_.CreatedAt.substring(0,$_.CreatedAt.Length -4)
$createdAt = [DateTime]::ParseExact($createdAtString, $formatString,[System.Globalization.CultureInfo]::InvariantCulture)
if($createdAt -lt (Get-Date).adddays(-1))
{
docker image rm $_.ID
}
}
}
exit 0
displayName: 'Remove old images [Port to PSRelease]'
# Cleanup is not critical it passes every time it runs
continueOnError: true
- powershell: |
Write-verbose "--docker info---" -verbose
docker info
Write-verbose "--docker image ls---" -verbose
docker image ls
Write-verbose "--docker container ls --all---" -verbose
docker container ls --all
exit 0
displayName: 'Capture docker info'
# Diagnostics is not critical it passes every time it runs
continueOnError: true
- powershell: |
tools/releaseBuild/vstsbuild.ps1 -ReleaseTag $(ReleaseTagVar) -Name win-$(Architecture)-symbols
displayName: 'Build Windows Universal - $(Architecture) Symbols zip'
- powershell: |
if ("$env:Architecture" -like 'fxdependent*')
{
$(Build.SourcesDirectory)\tools\releaseBuild\updateSigning.ps1 -SkipPwshExe
}
else
{
$(Build.SourcesDirectory)\tools\releaseBuild\updateSigning.ps1
}
displayName: 'Update Signing Xml'
- powershell: |
$vstsCommandString = "vso[task.setvariable variable=Symbols]${env:Symbols_$(Architecture)}"
Write-Host "sending " + $vstsCommandString
Write-Host "##$vstsCommandString"
displayName: 'Get Symbols path [Update build.json]'
- task: PkgESCodeSign@10
displayName: 'CodeSign $(Architecture)'
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
signConfigXml: '$(Build.SourcesDirectory)\tools\releaseBuild\signing.xml'
inPathRoot: '$(Symbols)'
outPathRoot: '$(Symbols)\signed'
binVersion: $(SigingVersion)
binVersionOverride: $(SigningVersionOverride)
condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true'))
- powershell: |
New-Item -ItemType Directory -Path $(Symbols)\signed -Force
displayName: 'Create empty signed folder'
condition: and(succeeded(), ne(variables['SHOULD_SIGN'], 'true'))
- powershell: |
tools/releaseBuild/vstsbuild.ps1 -ReleaseTag $(ReleaseTagVar) -Name win-$(Architecture)-package -BuildPath $(Symbols) -SignedFilesPath $(Symbols)\signed
displayName: 'Build Windows Universal - $(Architecture) Package'
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
displayName: 'Component Detection'
inputs:
sourceScanPath: '$(Build.SourcesDirectory)'
snapshotForceEnabled: true

View file

@ -1,8 +1,13 @@
parameters:
BuildConfiguration: release
BuildPlatform: any cpu
Architecture: x64
parentJob: ''
- name: BuildConfiguration
default: release
- name: BuildPlatform
default: any cpu
- name: Architecture
default: x64
- name: parentJob
default: ''
jobs:
- job: build_windows_${{ parameters.Architecture }}
displayName: Build Windows - ${{ parameters.Architecture }}
@ -28,11 +33,7 @@ jobs:
- template: insert-nuget-config-azfeed.yml
- powershell: |
Write-Host "##vso[task.setvariable variable=PowerShellRoot]/PowerShell"
$null = New-Item -ItemType Directory -Path /Powershell -Force
git clone $env:BUILD_REPOSITORY_LOCALPATH /PowerShell
displayName: Clone PowerShell Repo to /PowerShell
- template: cloneToOfficialPath.yml
- powershell: |

View file

@ -16,6 +16,7 @@ jobs:
steps:
- checkout: self
clean: true
fetchDepth: 1
- template: shouldSign.yml
- template: SetVersionVariables.yml

View file

@ -1,8 +1,12 @@
parameters:
BuildConfiguration: release
BuildPlatform: any cpu
Architecture: x64
parentJob: ''
- name: BuildConfiguration
default: release
- name: BuildPlatform
default: any cpu
- name: Architecture
default: x64
- name: parentJob
default: ''
jobs:
- job: sign_windows_${{ parameters.Architecture }}
@ -12,16 +16,24 @@ jobs:
pool:
name: Package ES Standard Build
variables:
BuildConfiguration: ${{ parameters.BuildConfiguration }}
BuildPlatform: ${{ parameters.BuildPlatform }}
Architecture: ${{ parameters.Architecture }}
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
- name: BuildConfiguration
value: ${{ parameters.BuildConfiguration }}
- name: BuildPlatform
value: ${{ parameters.BuildPlatform }}
- name: Architecture
value: ${{ parameters.Architecture }}
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
value: 1
- group: ESRP
steps:
- checkout: self
clean: true
- checkout: ComplianceRepo
clean: true
- template: shouldSign.yml
- template: SetVersionVariables.yml
parameters:
@ -59,20 +71,7 @@ jobs:
itemPattern: '**/*$(PkgFilter).zip'
downloadPath: '$(System.ArtifactsDirectory)\Symbols'
- powershell: |
Write-Host "##vso[task.setvariable variable=PowerShellRoot]/PowerShell"
if ((Test-Path "\PowerShell")) {
Remove-Item -Path "\PowerShell" -Force -Recurse -Verbose
}
else {
Write-Verbose -Verbose -Message "No cleanup required."
}
git clone --quiet $env:BUILD_REPOSITORY_LOCALPATH '\PowerShell'
displayName: Clone PowerShell Repo to /PowerShell
errorActionPreference: silentlycontinue
- template: cloneToOfficialPath.yml
- powershell: |
# cleanup previous install
@ -104,33 +103,65 @@ jobs:
Expand-Archive -Path $zipPath -Destination "$(System.ArtifactsDirectory)\$expandedFolder" -Force
displayName: Expand symbols zip
- powershell: |
if ("$env:Architecture" -like 'fxdependent*')
{
$(Build.SourcesDirectory)\tools\releaseBuild\updateSigning.ps1 -SkipPwshExe
}
else
{
$(Build.SourcesDirectory)\tools\releaseBuild\updateSigning.ps1
}
displayName: 'Update Signing Xml'
- pwsh: |
$fullSymbolsFolder = "$(System.ArtifactsDirectory)\$($env:SYMBOLSFOLDER)"
- task: PkgESCodeSign@10
displayName: 'CodeSign $(Architecture)'
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
signConfigXml: '$(Build.SourcesDirectory)\tools\releaseBuild\signing.xml'
inPathRoot: '$(System.ArtifactsDirectory)\$(SymbolsFolder)'
outPathRoot: '$(System.ArtifactsDirectory)\signed'
condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true'))
$filesToSignDirectory = "$(System.ArtifactsDirectory)\toBeSigned"
$null = New-Item -ItemType Directory -Path $filesToSignDirectory -Force
$signedFilesDirectory = "$(System.ArtifactsDirectory)\signed"
$null = New-Item -ItemType Directory -Path $signedFilesDirectory -Force
$itemsToCopyWithRecurse = @(
"$($fullSymbolsFolder)\*.ps1"
"$($fullSymbolsFolder)\Microsoft.PowerShell*.dll"
)
$itemsToCopy = @{
"$($fullSymbolsFolder)\*.ps1" = ""
"$($fullSymbolsFolder)\Microsoft.Management.Infrastructure.CimCmdlets.dll" = ""
"$($fullSymbolsFolder)\Microsoft.WSMan.*.dll" = ""
"$($fullSymbolsFolder)\Modules\CimCmdlets\CimCmdlets.psd1" = "Modules\CimCmdlets"
"$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Diagnostics\Diagnostics.format.ps1xml" = "Modules\Microsoft.PowerShell.Diagnostics"
"$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Diagnostics\Event.format.ps1xml" = "Modules\Microsoft.PowerShell.Diagnostics"
"$($fullSymbolsFolder)\Modules\Microsoft.PowerShell.Diagnostics\GetEvent.types.ps1xml" = "Modules\Microsoft.PowerShell.Diagnostics"
"$($fullSymbolsFolder)\Modules\Microsoft.WSMan.Management\Microsoft.WSMan.Management.psd1" = "Modules\Microsoft.WSMan.Management"
"$($fullSymbolsFolder)\Modules\Microsoft.WSMan.Management\WSMan.format.ps1xml" = "Modules\Microsoft.WSMan.Management"
"$($fullSymbolsFolder)\Modules\PSDiagnostics\PSDiagnostics.ps?1" = "Modules\PSDiagnostics"
"$($fullSymbolsFolder)\pwsh.dll" = ""
"$($fullSymbolsFolder)\System.Management.Automation.dll" = ""
}
if ("$env:Architecture" -notlike 'fxdependent*')
{
$itemsToCopy += @{"$($fullSymbolsFolder)\pwsh.exe" = ""}
}
Write-Verbose -verbose "recusively copying $($itemsToCopyWithRecurse | out-string) to $filesToSignDirectory"
Copy-Item -Path $itemsToCopyWithRecurse -Destination $filesToSignDirectory -Recurse -verbose
foreach($pattern in $itemsToCopy.Keys) {
$destinationFolder = Join-Path $filesToSignDirectory -ChildPath $itemsToCopy.$pattern
$null = New-Item -ItemType Directory -Path $destinationFolder -Force
Write-Verbose -verbose "copying $pattern to $destinationFolder"
Copy-Item -Path $pattern -Destination $destinationFolder -Recurse -verbose
}
displayName: 'Prepare files to be signed'
- template: EsrpSign.yml@ComplianceRepo
parameters:
buildOutputPath: $(System.ArtifactsDirectory)\toBeSigned
signOutputPath: $(System.ArtifactsDirectory)\signed
certificateId: "CP-230012"
pattern: |
**\*.dll
**\*.psd1
**\*.psm1
**\*.ps1xml
**\*.ps1
useMinimatch: true
- pwsh: |
New-Item -ItemType Directory -Path $(System.ArtifactsDirectory)\signed -Force
displayName: 'Create empty signed folder'
condition: and(succeeded(), ne(variables['SHOULD_SIGN'], 'true'))
- powershell: |
Import-Module $(PowerShellRoot)/build.psm1 -Force
Import-Module $(PowerShellRoot)/tools/packaging -Force
$signedFilesPath = '$(System.ArtifactsDirectory)\signed\'
@ -140,7 +171,7 @@ jobs:
$dlls = Get-ChildItem $BuildPath\*.dll -Recurse
$signatures = $dlls | Get-AuthenticodeSignature
$missingSignatures = $signatures | Where-Object { $_.status -eq 'notsigned'}| select-object -ExpandProperty Path
tools/releaseBuild/generatePackgeSigning.ps1 -ThirdPartyFiles $missingSignatures -path "$(System.ArtifactsDirectory)\thirtdparty.xml"
& "${env:REPOROOT}/tools/releaseBuild/generatePackgeSigning.ps1" -ThirdPartyFiles $missingSignatures -path "$(System.ArtifactsDirectory)\thirtdparty.xml"
displayName: Create ThirdParty Signing Xml
condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true'))

View file

@ -26,6 +26,7 @@ jobs:
steps:
- checkout: self
clean: true
fetchDepth: 1
- template: ./templates/SetVersionVariables.yml
parameters:

View file

@ -1,47 +0,0 @@
resources:
- repo: self
clean: true
queue:
name: Hosted Mac Internal
name: macOS_$(Build.SourceBranchName)_$(Build.BuildId)
steps:
#- task: <task type name>@<version>
# inputs:
# <task specific inputs>
# displayName: '<display name of task>'
- task: ShellScript@2
inputs:
scriptPath: 'tools/releaseBuild/setReleaseTag.sh'
args: '-ReleaseTag $(ReleaseTagVar) -Variable "ReleaseTagVar"'
displayName: 'Calculate Release Tag'
- task: ShellScript@2
inputs:
scriptPath: 'tools/installpsh-osx.sh'
displayName: 'Install pwsh'
- task: ShellScript@2
inputs:
scriptPath: 'tools/releaseBuild/macOS/createPowerShell.sh'
displayName: 'Create /PowerShell'
- powershell: |
Write-Host "##vso[task.setvariable variable=PowerShellRoot]/PowerShell"
git clone $env:BUILD_REPOSITORY_LOCALPATH /PowerShell
displayName: Clone PowerShell Repo to /PowerShell
- task: ShellScript@2
inputs:
scriptPath: 'tools/releaseBuild/macOS/PowerShellPackageVsts.sh'
args: '-location $(PowerShellRoot) -BootStrap'
displayName: 'Bootstrap VM'
- powershell: |
Import-Module $(Build.SourcesDirectory)/build.psm1 -Force
New-NugetConfigFile -NugetFeedUrl $(AzDevOpsFeed) -UserName $(AzDevOpsFeedUserName) -ClearTextPAT $(AzDevOpsFeedPAT) -FeedName AzDevOpsFeed -Destination "$(PowerShellRoot)/src/Modules"
if(-not (Test-Path "$(PowerShellRoot)/src/Modules/nuget.config"))
{
throw "nuget.config is not created"
}
displayName: 'Add nuget.config for AzDevOps feed for PSGallery modules '
- powershell: |
$env:AZDEVOPSFEEDPAT = '$(AzDevOpsFeedPAT)'
$(Build.SourcesDirectory)/tools/releaseBuild/macOS/PowerShellPackageVsts.ps1 -ReleaseTag $(ReleaseTagVar) -Destination $(System.ArtifactsDirectory) -ExtraPackage "tar" -location $(PowerShellRoot) -Build
$env:AZDEVOPSFEEDPAT = $null
displayName: 'Build and Package'