|
| 1 | +name: Microsoft.PowerShell.Archive-$(Build.BuildId) |
| 2 | +trigger: none |
| 3 | + |
| 4 | +pr: none |
| 5 | + |
| 6 | +variables: |
| 7 | + DOTNET_CLI_TELEMETRY_OPTOUT: 1 |
| 8 | + POWERSHELL_TELEMETRY_OPTOUT: 1 |
| 9 | + |
| 10 | +resources: |
| 11 | + repositories: |
| 12 | + - repository: ComplianceRepo |
| 13 | + type: github |
| 14 | + endpoint: ComplianceGHRepo |
| 15 | + name: PowerShell/compliance |
| 16 | + ref: master |
| 17 | + |
| 18 | +stages: |
| 19 | +- stage: Build |
| 20 | + displayName: Build |
| 21 | + pool: |
| 22 | + name: 1ES |
| 23 | + demands: |
| 24 | + - ImageOverride -equals PSMMS2019-Secure |
| 25 | + jobs: |
| 26 | + - job: Build_Job |
| 27 | + displayName: Build Microsoft.PowerShell.Archive |
| 28 | + variables: |
| 29 | + - group: ESRP |
| 30 | + steps: |
| 31 | + - checkout: self |
| 32 | + |
| 33 | + - task: UseDotNet@2 |
| 34 | + displayName: 'Get .NET 7.0 SDK' |
| 35 | + inputs: |
| 36 | + packageType: sdk |
| 37 | + version: 7.x |
| 38 | + includePreviewVersions: true |
| 39 | + |
| 40 | + - pwsh: | |
| 41 | + & $(Build.SourcesDirectory)/Microsoft.PowerShell.Archive/SimpleBuild.ps1 |
| 42 | + displayName: Build Microsoft.PowerShell.Archive module |
| 43 | + |
| 44 | + - pwsh: | |
| 45 | + Get-ChildItem "$(BuildOutDir)\*" -Recurse | Write-Verbose -Verbose |
| 46 | + displayName: Show BuildOutDirectory |
| 47 | + |
| 48 | + - pwsh: | |
| 49 | + $signSrcPath = "$(BuildOutDir)" |
| 50 | + # Set signing src path variable |
| 51 | + $vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}" |
| 52 | + Write-Host "sending " + $vstsCommandString |
| 53 | + Write-Host "##$vstsCommandString" |
| 54 | + # Get the module version |
| 55 | + $ManifestPath = Join-Path $(BuildOutDir) "Microsoft.PowerShell.Archive.psd1" |
| 56 | + $ManifestData = Import-PowerShellDataFile -Path $ManifestPath |
| 57 | + $Version = $ManifestData.ModuleVersion |
| 58 | + $signOutPath = "$(Build.SourcesDirectory)\signed\Microsoft.PowerShell.Archive\${Version}" |
| 59 | + $null = New-Item -ItemType Directory -Path $signOutPath |
| 60 | + # Set signing out path variable |
| 61 | + $vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}" |
| 62 | + Write-Host "sending " + $vstsCommandString |
| 63 | + Write-Host "##$vstsCommandString" |
| 64 | + # Set path variable for guardian codesign validation |
| 65 | + $vstsCommandString = "vso[task.setvariable variable=GDN_CODESIGN_TARGETDIRECTORY]${signOutPath}" |
| 66 | + Write-Host "sending " + $vstsCommandString |
| 67 | + Write-Host "##$vstsCommandString" |
| 68 | + displayName: Setup variables for signing |
| 69 | + |
| 70 | + - checkout: ComplianceRepo |
| 71 | + |
| 72 | + - task: UseDotNet@2 |
| 73 | + displayName: 'Get .NET 2.1 SDK' |
| 74 | + inputs: |
| 75 | + packageType: sdk |
| 76 | + version: 2.x |
| 77 | + includePreviewVersions: true |
| 78 | + |
| 79 | + - template: EsrpSign.yml@ComplianceRepo |
| 80 | + parameters: |
| 81 | + # the folder which contains the binaries to sign |
| 82 | + buildOutputPath: $(signSrcPath) |
| 83 | + # the location to put the signed output |
| 84 | + signOutputPath: $(signOutPath) |
| 85 | + # the certificate ID to use |
| 86 | + certificateId: "CP-230012" |
| 87 | + # the file pattern to use, comma separated |
| 88 | + pattern: '*.psd1,*.dll' |
| 89 | + |
| 90 | + - template: Sbom.yml@ComplianceRepo |
| 91 | + parameters: |
| 92 | + BuildDropPath: $(signOutPath) |
| 93 | + Build_Repository_Uri: 'https://github.com/PowerShell/Microsoft.PowerShell.Archive' |
| 94 | + |
| 95 | + - pwsh: | |
| 96 | + Get-ChildItem $(signOutPath) -Recurse | Write-Output |
| 97 | +
|
| 98 | + - pwsh: | |
| 99 | + Set-Location "$(Build.SourcesDirectory)" |
| 100 | + # signOutPath points to directory with version number -- we want to point to the parent of that directory |
| 101 | + $ModulePath = Split-Path $(signOutPath) -Parent |
| 102 | + $(Build.SourcesDirectory)/Microsoft.PowerShell.Archive/.azdevops/SignAndPackageModule.ps1 -SignedPath $ModulePath |
| 103 | + Get-ChildItem -recurse -file -name | Write-Verbose -Verbose |
| 104 | + displayName: package build |
| 105 | + |
| 106 | + - publish: "$(signSrcPath)" |
| 107 | + artifact: build |
| 108 | + displayName: Publish build |
| 109 | + |
| 110 | +- stage: compliance |
| 111 | + displayName: Compliance |
| 112 | + dependsOn: Build |
| 113 | + jobs: |
| 114 | + - job: Compliance_Job |
| 115 | + pool: |
| 116 | + name: 1ES # Package ES CodeHub Lab E |
| 117 | + steps: |
| 118 | + - checkout: self |
| 119 | + - checkout: ComplianceRepo |
| 120 | + - download: current |
| 121 | + artifact: build |
| 122 | + |
| 123 | + - pwsh: | |
| 124 | + Get-ChildItem -Path "$(Pipeline.Workspace)\build" -Recurse |
| 125 | + displayName: Capture downloaded artifacts |
| 126 | + - template: script-module-compliance.yml@ComplianceRepo |
| 127 | + parameters: |
| 128 | + # component-governance |
| 129 | + sourceScanPath: '$(Build.SourcesDirectory)\Microsoft.PowerShell.Archive\src' |
| 130 | + # credscan |
| 131 | + suppressionsFile: '' |
| 132 | + # TermCheck |
| 133 | + optionsRulesDBPath: '' |
| 134 | + optionsFTPath: '' |
| 135 | + # tsa-upload |
| 136 | + codeBaseName: 'PSNativeCommandProxy_2020' |
| 137 | + # selections |
| 138 | + APIScan: false # set to false when not using Windows APIs. |
0 commit comments