|
| 1 | +steps: |
| 2 | +- task: DownloadPipelineArtifact@2 |
| 3 | + inputs: |
| 4 | + buildType: current |
| 5 | + artifactName: release |
| 6 | + targetPath: "$(System.ArtifactsDirectory)/release" |
| 7 | + displayName: Download native packages |
| 8 | + |
| 9 | +- task: DownloadPipelineArtifact@2 |
| 10 | + inputs: |
| 11 | + buildType: current |
| 12 | + artifactName: signed |
| 13 | + targetPath: "$(System.ArtifactsDirectory)/signed" |
| 14 | + displayName: Download signed windows native packages |
| 15 | + |
| 16 | +- powershell: | |
| 17 | + $null = New-Item $(PackageRoot) -ItemType Directory -Force -Verbose |
| 18 | + if(-not (Test-Path '$(System.ArtifactsDirectory)/release' )) |
| 19 | + { |
| 20 | + New-Item -ItemType Directory -Path '$(System.ArtifactsDirectory)/release' -Force |
| 21 | + } |
| 22 | + Invoke-WebRequest -Uri '$(PSRPBlobUrl)' -OutFile $(System.ArtifactsDirectory)/release/psrp.zip -Verbose |
| 23 | + displayName: 'Download PSRP package' |
| 24 | + |
| 25 | +- powershell: 'Get-ChildItem $(System.ArtifactsDirectory)/release' |
| 26 | + displayName: 'Capture downloaded zips' |
| 27 | + |
| 28 | +- powershell: | |
| 29 | + $extractedRoot = New-Item $(System.ArtifactsDirectory)/uncompressed -ItemType Directory -Force -Verbose |
| 30 | +
|
| 31 | + Get-ChildItem $(System.ArtifactsDirectory)/release/*.zip | ForEach-Object { |
| 32 | + $baseName = $_.BaseName |
| 33 | + if($baseName -match 'x64_arm') { |
| 34 | + Write-Verbose "Skipping expanding file $_.Name" -Verbose |
| 35 | + } |
| 36 | + else { |
| 37 | + $folderPath = Join-Path $extractedRoot $baseName |
| 38 | + Expand-Archive $_.FullName -DestinationPath $folderPath -Force |
| 39 | + } |
| 40 | + } |
| 41 | +
|
| 42 | + Write-Host "Extracted files:" |
| 43 | + Get-ChildItem -Recurse $extractedRoot -File |
| 44 | + displayName: 'Extract All Zips' |
| 45 | + |
| 46 | +- template: compliance.yml |
| 47 | + |
| 48 | +- template: upload.yml |
| 49 | + parameters: |
| 50 | + fileName: 'x64_arm64-symbols.zip' |
| 51 | + sourcePath: '$(System.ArtifactsDirectory)\release\x64_arm64-symbols.zip' |
| 52 | +- template: upload.yml |
| 53 | + parameters: |
| 54 | + fileName: 'x64-symbols.zip' |
| 55 | + sourcePath: '$(System.ArtifactsDirectory)\release\x64-symbols.zip' |
| 56 | +- template: upload.yml |
| 57 | + parameters: |
| 58 | + fileName: 'x64_arm-symbols.zip' |
| 59 | + sourcePath: '$(System.ArtifactsDirectory)\release\x64_arm-symbols.zip' |
| 60 | +- template: upload.yml |
| 61 | + parameters: |
| 62 | + fileName: 'x86-symbols.zip' |
| 63 | + sourcePath: '$(System.ArtifactsDirectory)\release\x86-symbols.zip' |
| 64 | + |
| 65 | +- task: NuGetToolInstaller@0 |
| 66 | + displayName: 'Install NuGet 5.3.1' |
| 67 | + inputs: |
| 68 | + versionSpec: 5.3.1 |
| 69 | + |
| 70 | +- powershell: | |
| 71 | + $Branch = $env:BUILD_SOURCEBRANCH |
| 72 | + $branchOnly = $Branch -replace '^refs/heads/'; |
| 73 | + $branchOnly = $branchOnly -replace '[_\-]' |
| 74 | +
|
| 75 | + $packageVersion = if($env:PACKAGE_VERSION -eq 'fromBranch' -or !$env:PACKAGE_VERSION) |
| 76 | + { |
| 77 | + if($Branch -match '^.*(release[-/])') |
| 78 | + { |
| 79 | + Write-verbose "release branch:" -verbose |
| 80 | + $Branch -replace '^.*(release[-/]v)' |
| 81 | + } |
| 82 | + else |
| 83 | + { |
| 84 | + "0.0.0" |
| 85 | + } |
| 86 | + } |
| 87 | + else { |
| 88 | + "0.0.0" |
| 89 | + } |
| 90 | +
|
| 91 | + $vstsCommandString = "vso[task.setvariable variable=NugetPackageVersion]$packageVersion" |
| 92 | + Write-Verbose -Message "setting $Variable to $packageVersion" -Verbose |
| 93 | + Write-Host -Object "##$vstsCommandString" |
| 94 | +
|
| 95 | + displayName: Set NuGetPackageVersion |
| 96 | + |
| 97 | +- powershell: | |
| 98 | + Import-Module $(Build.SourcesDirectory)\build.psm1 |
| 99 | + $PackageRoot = New-Item -ItemType Directory -Path $(System.ArtifactsDirectory)\NugetPackage |
| 100 | +
|
| 101 | + $WindowsX64ZipPath = Join-Path "$(System.ArtifactsDirectory)/signed" 'win-x64.zip' |
| 102 | + $WindowsX86ZipPath = Join-Path "$(System.ArtifactsDirectory)/signed" 'win-x86.zip' |
| 103 | + $WindowsARMZipPath = Join-Path "$(System.ArtifactsDirectory)/signed" 'win-x64_arm.zip' |
| 104 | + $WindowsARM64ZipPath = Join-Path "$(System.ArtifactsDirectory)/signed" 'win-x64_arm64.zip' |
| 105 | + $LinuxZipPath = Join-Path "$(System.ArtifactsDirectory)/release" 'linux-x64-symbols.zip' |
| 106 | + $LinuxARMZipPath = Join-Path "$(System.ArtifactsDirectory)/release" 'linux-arm-symbols.zip' |
| 107 | + $LinuxARM64ZipPath = Join-Path "$(System.ArtifactsDirectory)/release" 'linux-arm64-symbols.zip' |
| 108 | + $LinuxAlpineZipPath = Join-Path "$(System.ArtifactsDirectory)/release" 'linux-musl-x64-symbols.zip' |
| 109 | + $macOSZipPath = Join-Path "$(System.ArtifactsDirectory)/release" 'osx-symbols.zip' |
| 110 | + $psrpZipPath = Join-Path "$(System.ArtifactsDirectory)/release" 'psrp.zip' |
| 111 | +
|
| 112 | + Start-BuildPowerShellNativePackage -PackageRoot $PackageRoot -Version $(NugetPackageVersion) -WindowsX64ZipPath $WindowsX64ZipPath -WindowsX86ZipPath $WindowsX86ZipPath -WindowsARMZipPath $WindowsARMZipPath -WindowsARM64ZipPath $WindowsARM64ZipPath -LinuxZipPath $LinuxZipPath -LinuxARMZipPath $LinuxARMZipPath -LinuxARM64ZipPath $LinuxARM64ZipPath -LinuxAlpineZipPath $LinuxAlpineZipPath -macOSZipPath $macOSZipPath -psrpZipPath $psrpZipPath -NuGetOutputPath $(NuGetPackagePath) |
| 113 | +
|
| 114 | + displayName: 'Build NuGet package' |
| 115 | + |
| 116 | +- powershell: 'Get-Childitem $(NuGetPackagePath)' |
| 117 | + displayName: 'Capture nuget package' |
| 118 | + |
| 119 | +- powershell: | |
| 120 | + ## Get the nuget file paths |
| 121 | + $files = (Get-ChildItem $(NuGetPackagePath)\*.nupkg).FullName |
| 122 | +
|
| 123 | + if($files.Count -lt 1) { throw "No packages available to publish" } |
| 124 | +
|
| 125 | + & $(Build.SourcesDirectory)\tools\releaseBuild\generatePackgeSigning.ps1 -Path "$(NuGetPackagePath)\NugetSigning.xml" -NuPkgFiles $files |
| 126 | +
|
| 127 | + displayName: 'Generate signing file' |
| 128 | + |
| 129 | +- powershell: 'Get-Content $(NuGetPackagePath)\NugetSigning.xml' |
| 130 | + displayName: 'Capture package signing file' |
| 131 | + |
| 132 | +- task: PkgESCodeSign@10 |
| 133 | + displayName: 'Package ES - CodeSign $(NuGetPackagePath)\NugetSigning.xml' |
| 134 | + env: |
| 135 | + SYSTEM_ACCESSTOKEN: $(System.AccessToken) |
| 136 | + inputs: |
| 137 | + signConfigXml: '$(NuGetPackagePath)\NugetSigning.xml' |
| 138 | + inPathRoot: ' $(NuGetPackagePath)' |
| 139 | + outPathRoot: '$(System.ArtifactsDirectory)\signed' |
| 140 | + condition: ne(variables['SKIP_SIGNING'], 'True') |
| 141 | + |
| 142 | +- powershell: | |
| 143 | + Copy-Item $(NuGetPackagePath)\*.nupkg -DestinationPath '$(System.ArtifactsDirectory)\signed' -Force -Verbose |
| 144 | + displayName: Copy unsigned nuget packge as signing is disabled |
| 145 | + condition: eq(variables['SKIP_SIGNING'], 'True') |
| 146 | + |
| 147 | +- powershell: | |
| 148 | + Import-Module $env:BUILD_SOURCESDIRECTORY\build.psm1 -Force |
| 149 | +
|
| 150 | + $packages = Get-ChildItem -Recurse $(System.ArtifactsDirectory)\signed\*.nupkg -Verbose |
| 151 | +
|
| 152 | + if ($packages.Count -eq 0) |
| 153 | + { |
| 154 | + throw "No signed package found at: $(System.ArtifactsDirectory)\signed" |
| 155 | + } |
| 156 | +
|
| 157 | + $packages | ForEach-Object { Start-NativeExecution -sb { nuget.exe verify -All $_.FullName } } |
| 158 | + displayName: 'Validate NuGet package is signed' |
| 159 | + |
| 160 | +- template: uploadArtifact.yml |
| 161 | + parameters: |
| 162 | + artifactPath: '$(System.ArtifactsDirectory)\signed' |
| 163 | + artifactFilter: 'Microsoft.PowerShell.Native.$(NugetPackageVersion).nupkg' |
| 164 | + artifactName: 'finalResults' |
0 commit comments