|
| 1 | +name: $(BuildDefinitionName)-$(date:yyMM).$(date:dd)$(rev:rrr) |
| 2 | +trigger: |
| 3 | + # Batch merge builds together while a merge build is running |
| 4 | + batch: true |
| 5 | + branches: |
| 6 | + include: |
| 7 | + - master |
| 8 | +pr: |
| 9 | + branches: |
| 10 | + include: |
| 11 | + - master |
| 12 | + |
| 13 | +stages: |
| 14 | +- stage: Build |
| 15 | + displayName: Build PowerShellGet Module Package |
| 16 | + jobs: |
| 17 | + - job: BuildPkg |
| 18 | + displayName: Build Package |
| 19 | + pool: |
| 20 | + name: Package ES CodeHub Lab E |
| 21 | + |
| 22 | + steps: |
| 23 | + - powershell: | |
| 24 | + $powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell' |
| 25 | + Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1 |
| 26 | + ./install-powershell.ps1 -Destination $powerShellPath |
| 27 | + $vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH" |
| 28 | + Write-Host "sending " + $vstsCommandString |
| 29 | + Write-Host "##$vstsCommandString" |
| 30 | + displayName: Install PowerShell Core |
| 31 | +
|
| 32 | + - task: UseDotNet@2 |
| 33 | + displayName: 'Install .NET Core 3.1.401 sdk' |
| 34 | + inputs: |
| 35 | + packageType: sdk |
| 36 | + version: 3.1.401 |
| 37 | + |
| 38 | + - task: NuGetToolInstaller@1 |
| 39 | + displayName: 'Install NuGet 5.6.0' |
| 40 | + inputs: |
| 41 | + checkLatest: false |
| 42 | + version: 5.6.0 |
| 43 | + |
| 44 | + - task: PkgESSetupBuild@10 |
| 45 | + displayName: 'Package ES - Setup Build' |
| 46 | + inputs: |
| 47 | + productName: PowerShellGet |
| 48 | + useDfs: false |
| 49 | + branchVersion: true |
| 50 | + disableMsbuildVersion: true |
| 51 | + |
| 52 | + - pwsh: | |
| 53 | + Get-ChildItem -Path env: |
| 54 | + displayName: Capture environment for build |
| 55 | + condition: succeededOrFailed() |
| 56 | +
|
| 57 | + - pwsh: | |
| 58 | + $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' |
| 59 | + if (Test-Path -Path $modulePath) { |
| 60 | + Write-Verbose -Verbose "Deleting existing temp module path: $modulePath" |
| 61 | + Remove-Item -Path $modulePath -Recurse -Force -ErrorAction Ignore |
| 62 | + } |
| 63 | + if (! (Test-Path -Path $modulePath)) { |
| 64 | + Write-Verbose -Verbose "Creating new temp module path: $modulePath" |
| 65 | + $null = New-Item -Path $modulePath -ItemType Directory |
| 66 | + } |
| 67 | + displayName: Create temporary module path for PSPackageProject |
| 68 | +
|
| 69 | + - pwsh: | |
| 70 | + $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' |
| 71 | + Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.0-beta10 -AllowPrerelease -Force |
| 72 | + displayName: Install PowerShellGet Module |
| 73 | +
|
| 74 | + - pwsh: | |
| 75 | + $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' |
| 76 | + Save-Module -Name "platyPS" -Path $modulePath -Force |
| 77 | + displayName: Install platyPS dependency |
| 78 | +
|
| 79 | + - pwsh: | |
| 80 | + $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' |
| 81 | + Save-Module -Name "PSScriptAnalyzer" -Path $modulePath -RequiredVersion 1.18.0 -Force |
| 82 | + displayName: Install PSScriptAnalyzer dependency |
| 83 | +
|
| 84 | + - pwsh: | |
| 85 | + $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' |
| 86 | + Save-Module -Name "Pester" -MaximumVersion 4.99 -Path $modulePath -Force |
| 87 | + displayName: Install Pester version 4 |
| 88 | +
|
| 89 | + - pwsh: | |
| 90 | + $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' |
| 91 | + Save-Module -Name PSPackageProject -Path $modulePath -Force |
| 92 | + displayName: Install PSPackageProject module |
| 93 | +
|
| 94 | + - pwsh: | |
| 95 | + $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' |
| 96 | + $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath |
| 97 | + $modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject |
| 98 | + Write-Verbose -Verbose "Importing PSPackageProject from: $modPath" |
| 99 | + Import-Module -Name $modPath -Force |
| 100 | + # |
| 101 | + # First build for netstandard2.0 framework |
| 102 | + $(Build.SourcesDirectory)/build.ps1 -Build -Clean -BuildConfiguration Release -BuildFramework 'netstandard2.0' |
| 103 | + # Next build for net472 framework |
| 104 | + $(Build.SourcesDirectory)/build.ps1 -Build -BuildConfiguration Release -BuildFramework 'net472' |
| 105 | + displayName: Build and publish artifact |
| 106 | +
|
| 107 | + - pwsh: | |
| 108 | + $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' |
| 109 | + $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath |
| 110 | + $modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject |
| 111 | + Write-Verbose -Verbose "Importing PSPackageProject from: $modPath" |
| 112 | + Import-Module -Name $modPath -Force |
| 113 | + # |
| 114 | + $config = Get-PSPackageProjectConfiguration |
| 115 | + $signSrcPath = "$($config.BuildOutputPath)\$($config.ModuleName)" |
| 116 | + $signOutPath = "$($config.SignedOutputPath)\$($config.ModuleName)" |
| 117 | + if (! (Test-Path -Path $signOutPath)) { |
| 118 | + $null = New-Item -Path $signOutPath -ItemType Directory |
| 119 | + } |
| 120 | + Write-Host "Signed output path is: $signOutPath" |
| 121 | + $signXmlPath = "$($config.SourcePath)\..\sign-module-files.xml" |
| 122 | + # Set signing src path variable |
| 123 | + $vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}" |
| 124 | + Write-Host "sending " + $vstsCommandString |
| 125 | + Write-Host "##$vstsCommandString" |
| 126 | + # Set signing out path variable |
| 127 | + $vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}" |
| 128 | + Write-Host "sending " + $vstsCommandString |
| 129 | + Write-Host "##$vstsCommandString" |
| 130 | + # Set signing xml path |
| 131 | + $vstsCommandString = "vso[task.setvariable variable=signXmlPath]${signXmlPath}" |
| 132 | + Write-Host "sending " + $vstsCommandString |
| 133 | + Write-Host "##$vstsCommandString" |
| 134 | + displayName: Set up for code signing |
| 135 | +
|
| 136 | + - pwsh: | |
| 137 | + Get-ChildItem -Path env: |
| 138 | + displayName: Capture environment for module code signing |
| 139 | + condition: succeededOrFailed() |
| 140 | +
|
| 141 | + - task: PkgESCodeSign@10 |
| 142 | + displayName: Sign build files |
| 143 | + env: |
| 144 | + SYSTEM_ACCESSTOKEN: $(System.AccessToken) |
| 145 | + inputs: |
| 146 | + signConfigXml: '$(signXmlPath)' |
| 147 | + inPathRoot: '$(signSrcPath)' |
| 148 | + outPathRoot: '$(signOutPath)' |
| 149 | + binVersion: Production |
| 150 | + binVersionOverride: '' |
| 151 | + condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), ne(variables['SkipSigning'], 'True')) |
| 152 | + |
| 153 | + - pwsh: | |
| 154 | + $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' |
| 155 | + $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath |
| 156 | + $modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject |
| 157 | + Write-Verbose -Verbose "Importing PSPackageProject from: $modPath" |
| 158 | + Import-Module -Name $modPath -Force |
| 159 | + # |
| 160 | + if ($env:SkipSigning -eq 'True') |
| 161 | + { |
| 162 | + $(Build.SourcesDirectory)/build.ps1 -Publish |
| 163 | + } |
| 164 | + else |
| 165 | + { |
| 166 | + $(Build.SourcesDirectory)/build.ps1 -Publish -Signed |
| 167 | + } |
| 168 | + displayName: Create module artifact |
| 169 | +
|
| 170 | +- stage: Compliance |
| 171 | + displayName: Compliance |
| 172 | + dependsOn: Build |
| 173 | + jobs: |
| 174 | + - job: ComplianceJob |
| 175 | + pool: |
| 176 | + name: Package ES CodeHub Lab E |
| 177 | + steps: |
| 178 | + - template: compliance.yml |
| 179 | + |
| 180 | +- stage: Test |
| 181 | + displayName: Test Package |
| 182 | + dependsOn: Build |
| 183 | + jobs: |
| 184 | + - template: test.yml |
| 185 | + parameters: |
| 186 | + jobName: TestPkgWin |
| 187 | + displayName: PowerShell Core on Windows |
| 188 | + imageName: windows-2019 |
| 189 | + |
| 190 | + - template: test.yml |
| 191 | + parameters: |
| 192 | + jobName: TestPkgUbuntu16 |
| 193 | + displayName: PowerShell Core on Ubuntu 16.04 |
| 194 | + imageName: ubuntu-16.04 |
| 195 | + |
| 196 | + - template: test.yml |
| 197 | + parameters: |
| 198 | + jobName: TestPkgWinMacOS |
| 199 | + displayName: PowerShell Core on macOS |
| 200 | + imageName: macOS-10.14 |
| 201 | + |
| 202 | +- stage: Release |
| 203 | + displayName: Release Package |
| 204 | + condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), eq(variables['Publish'], 'True')) |
| 205 | + jobs: |
| 206 | + - template: release.yml |
0 commit comments