Skip to content

Commit 34bdaf5

Browse files
Merge pull request #1528 from PowerShell/andschwa/automated-pipeline
Automate entire release process
2 parents a5e23e3 + 85eae62 commit 34bdaf5

7 files changed

+110
-123
lines changed

.github/workflows/codeql-analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
- name: Build
3939
shell: pwsh
40-
run: scripts/azurePipelinesBuild.ps1
40+
run: tools/azurePipelinesBuild.ps1
4141

4242
- name: Perform CodeQL Analysis
4343
uses: github/codeql-action/analyze@v1

.vsts-ci/azure-pipelines-release.yml

+41-18
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Release-$(Build.SourceBranchName)-$(Date:yyyyMMdd)$(Rev:.rr)
2+
13
variables:
24
# Don't download unneeded packages
35
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
@@ -18,24 +20,45 @@ resources:
1820
repositories:
1921
- repository: ComplianceRepo
2022
type: github
21-
endpoint: ComplianceGHRepo
23+
endpoint: GitHub
2224
name: PowerShell/compliance
25+
- repository: vscode-powershell
26+
type: git
27+
name: vscode-powershell
28+
29+
stages:
30+
- stage: Build
31+
displayName: Build the release
32+
jobs:
33+
- job: Build
34+
pool:
35+
vmImage: vs2017-win2016
36+
steps:
37+
- template: templates/ci-general.yml
2338

24-
jobs:
25-
- job: 'ReleaseBuild'
26-
displayName: 'Build release'
27-
pool:
28-
vmImage: 'vs2017-win2016'
29-
steps:
30-
- template: templates/ci-general.yml
39+
- stage: Sign
40+
displayName: Sign the release
41+
jobs:
42+
- job: Sign
43+
pool:
44+
name: 1ES
45+
demands: ImageOverride -equals MMS2019
46+
variables:
47+
- group: ESRP
48+
steps:
49+
- template: templates/release-general.yml
3150

32-
- job: 'SignBuild'
33-
displayName: Signing Build
34-
dependsOn: 'ReleaseBuild'
35-
pool:
36-
name: '1ES'
37-
demands: ImageOverride -equals MMS2019
38-
variables:
39-
- group: ESRP
40-
steps:
41-
- template: templates/release-general.yml
51+
- stage: Publish
52+
displayName: Publish the draft release
53+
jobs:
54+
- deployment: Publish
55+
environment: PowerShellEditorServices
56+
pool:
57+
name: 1ES
58+
variables:
59+
- group: Publish
60+
strategy:
61+
runOnce:
62+
deploy:
63+
steps:
64+
- template: templates/publish-general.yml

.vsts-ci/templates/ci-general.yml

+20-37
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,26 @@
11
parameters:
2-
pwsh: true
2+
- name: pwsh
3+
type: boolean
4+
default: true
35

46
steps:
5-
- powershell: |
6-
Write-Host "Installing PowerShell Daily..."
7+
- pwsh: '$PSVersionTable'
8+
displayName: PowerShell version
79

8-
# Use `AGENT_TEMPDIRECTORY` to make sure the downloaded PowerShell is cleaned up.
9-
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
10-
Invoke-WebRequest -Uri https://aka.ms/install-powershell.ps1 -OutFile ./install-powershell.ps1
10+
- task: PowerShell@2
11+
displayName: Build and test
12+
inputs:
13+
filePath: tools/azurePipelinesBuild.ps1
14+
pwsh: ${{ parameters.pwsh }}
1115

12-
./install-powershell.ps1 -Destination $powerShellPath -Daily
16+
- publish: module
17+
artifact: PowerShellEditorServices-Build-$(System.JobId)
18+
displayName: Publish unsigned pipeline artifacts
19+
condition: succeededOrFailed()
1320

14-
# Using `prependpath` to update the PATH just for this build.
15-
Write-Host "##vso[task.prependpath]$powerShellPath"
16-
displayName: Install PowerShell Daily
17-
continueOnError: true
18-
19-
- pwsh: '$PSVersionTable'
20-
displayName: Display PowerShell version information
21-
22-
- pwsh: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
23-
displayName: Set Build Name for Non-PR
24-
condition: ne(variables['Build.Reason'], 'PullRequest')
25-
- task: PowerShell@2
26-
inputs:
27-
filePath: scripts/azurePipelinesBuild.ps1
28-
pwsh: ${{ parameters.pwsh }}
29-
- task: PublishTestResults@2
30-
inputs:
31-
testRunner: VSTest
32-
testResultsFiles: '**/*.trx'
33-
condition: succeededOrFailed()
34-
- task: PublishTestResults@2
35-
inputs:
36-
testRunner: NUnit
37-
testResultsFiles: '**/TestResults.xml'
38-
condition: succeededOrFailed()
39-
- task: PublishBuildArtifacts@1
40-
inputs:
41-
ArtifactName: PowerShellEditorServices-CI
42-
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
43-
condition: succeededOrFailed()
21+
- task: PublishTestResults@2
22+
displayName: Publish test results
23+
inputs:
24+
testRunner: VSTest
25+
testResultsFiles: '**/*.trx'
26+
condition: succeededOrFailed()
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
steps:
2+
- checkout: self
3+
- checkout: vscode-powershell
4+
- download: current
5+
artifact: PowerShellEditorServices
6+
displayName: Download signed pipeline artifacts
7+
- pwsh: |
8+
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null
9+
Install-Module -Name PowerShellForGitHub -Scope CurrentUser -Force -Confirm:$false
10+
Import-Module '$(Build.SourcesDirectory)/vscode-powershell/tools/ReleaseTools.psm1'
11+
Set-GitHubConfiguration -SuppressTelemetryReminder
12+
$password = ConvertTo-SecureString -String '$(GitHubToken)' -AsPlainText -Force
13+
Set-GitHubAuthentication -Credential (New-Object System.Management.Automation.PSCredential ("token", $password))
14+
New-DraftRelease -RepositoryName PowerShellEditorServices -Assets '$(Pipeline.Workspace)/PowerShellEditorServices/PowerShellEditorServices.zip'
15+
displayName: Drafting a GitHub Release
+32-29
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
steps:
22

3-
- task: DownloadBuildArtifacts@0
4-
displayName: 'Download Build Artifacts'
5-
inputs:
6-
downloadType: specific
7-
8-
- task: ExtractFiles@1
9-
displayName: 'Extract Build Zip'
10-
inputs:
11-
archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/PowerShellEditorServices-CI/PowerShellEditorServices*.zip'
12-
destinationFolder: '$(Build.ArtifactStagingDirectory)/PowerShellEditorServices'
3+
- download: current
4+
displayName: Download unsigned pipeline artifacts
135

146
- checkout: ComplianceRepo
15-
displayName: 'Checkout the ComplianceRepo'
167

8+
# NOTE: The signing templates explicitly copy everything along as they run, so
9+
# the last output path has every signed (and intentionally unsigned) file.
1710
- template: EsrpSign.yml@ComplianceRepo
1811
parameters:
19-
buildOutputPath: '$(Build.ArtifactStagingDirectory)/PowerShellEditorServices'
20-
signOutputPath: '$(Build.ArtifactStagingDirectory)/FirstPartySigned'
21-
alwaysCopy: true # So publishing works
22-
certificateId: 'CP-230012' # Authenticode certificate
23-
useMinimatch: true # This enables the use of globbing
12+
buildOutputPath: $(Pipeline.Workspace)/PowerShellEditorServices-Build-*
13+
signOutputPath: $(Pipeline.Workspace)/FirstPartySigned
14+
alwaysCopy: true
15+
certificateId: CP-230012 # Authenticode certificate
2416
shouldSign: true # We always want to sign
17+
useMinimatch: true # This enables the use of globbing
2518
pattern: |
2619
# PowerShellEditorServices Script
2720
PowerShellEditorServices/*.{ps1,psd1,psm1,ps1xml}
@@ -35,12 +28,12 @@ steps:
3528
3629
- template: EsrpSign.yml@ComplianceRepo
3730
parameters:
38-
buildOutputPath: '$(Build.ArtifactStagingDirectory)/FirstPartySigned'
39-
signOutputPath: '$(Build.ArtifactStagingDirectory)/ThirdPartySigned'
40-
alwaysCopy: true # So publishing works
41-
certificateId: 'CP-231522' # Third-party certificate
42-
useMinimatch: true # This enables the use of globbing
31+
buildOutputPath: $(Pipeline.Workspace)/FirstPartySigned
32+
signOutputPath: $(Pipeline.Workspace)/ThirdPartySigned
33+
alwaysCopy: true
34+
certificateId: CP-231522 # Third-party certificate
4335
shouldSign: true # We always want to sign
36+
useMinimatch: true # This enables the use of globbing
4437
pattern: |
4538
**/MediatR.dll
4639
**/Nerdbank.Streams.dll
@@ -49,27 +42,37 @@ steps:
4942
**/Serilog*.dll
5043
**/UnixConsoleEcho.dll
5144
52-
- publish: $(Build.ArtifactStagingDirectory)/ThirdPartySigned
45+
- task: ArchiveFiles@2
46+
displayName: Zip finished assets
47+
inputs:
48+
rootFolderOrFile: $(Pipeline.Workspace)/ThirdPartySigned
49+
includeRootFolder: false
50+
archiveType: zip
51+
archiveFile: PowerShellEditorServices.zip
52+
replaceExistingArchive: true
53+
verbose: true
54+
55+
- publish: PowerShellEditorServices.zip
5356
artifact: PowerShellEditorServices
54-
displayName: 'Publish signed (and unsigned) artifacts'
57+
displayName: Publish signed pipeline artifacts
5558

5659
- checkout: self
5760

5861
- template: assembly-module-compliance.yml@ComplianceRepo
5962
parameters:
6063
# binskim
61-
AnalyzeTarget: '$(Build.ArtifactStagingDirectory)/*.dll'
64+
AnalyzeTarget: $(Pipeline.Workspace)/*.dll
6265
AnalyzeSymPath: 'SRV*'
6366
# component-governance
64-
sourceScanPath: '$(Build.SourcesDirectory)/PowerShellEditorServices'
67+
sourceScanPath: $(Build.SourcesDirectory)/PowerShellEditorServices
6568
# credscan
6669
suppressionsFile: ''
6770
# TermCheck AKA PoliCheck
68-
targetArgument: '$(Build.SourcesDirectory)/PowerShellEditorServices'
69-
optionsUEPATH: '$(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/UserExclusions.xml'
71+
targetArgument: $(Build.SourcesDirectory)/PowerShellEditorServices
72+
optionsUEPATH: $(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/UserExclusions.xml
7073
optionsRulesDBPath: ''
71-
optionsFTPath: '$(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/FileTypeSet.xml'
74+
optionsFTPath: $(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/FileTypeSet.xml
7275
# tsa-upload
73-
codeBaseName: 'PowerShell_PowerShellEditorServices_20210201'
76+
codeBaseName: PowerShell_PowerShellEditorServices_20210201
7477
# selections
7578
APIScan: false

PowerShellEditorServices.build.ps1

+1-38
Original file line numberDiff line numberDiff line change
@@ -146,31 +146,6 @@ task Clean BinClean,{
146146
}
147147
}
148148

149-
task GetProductVersion -Before PackageModule, UploadArtifacts {
150-
[xml]$props = Get-Content .\PowerShellEditorServices.Common.props
151-
152-
$script:BuildNumber = 9999
153-
$script:VersionSuffix = $props.Project.PropertyGroup.VersionSuffix
154-
155-
if ($env:TF_BUILD) {
156-
# SYSTEM_PHASENAME is the Job name.
157-
# Job names can only include `_` but that's not a valid character for versions.
158-
$jobname = $env:SYSTEM_PHASENAME -replace '_', ''
159-
$script:BuildNumber = "$jobname-$env:BUILD_BUILDID"
160-
}
161-
162-
if ($script:VersionSuffix -ne $null) {
163-
$script:VersionSuffix = "$script:VersionSuffix-$script:BuildNumber"
164-
}
165-
else {
166-
$script:VersionSuffix = "$script:BuildNumber"
167-
}
168-
169-
$script:FullVersion = "$($props.Project.PropertyGroup.VersionPrefix)-$script:VersionSuffix"
170-
171-
Write-Host "`n### Product Version: $script:FullVersion`n" -ForegroundColor Green
172-
}
173-
174149
task CreateBuildInfo -Before Build {
175150
$buildVersion = "<development-build>"
176151
$buildOrigin = "Development"
@@ -435,17 +410,5 @@ task BuildCmdletHelp {
435410
New-ExternalHelp -Path $PSScriptRoot\module\PowerShellEditorServices.VSCode\docs -OutputPath $PSScriptRoot\module\PowerShellEditorServices.VSCode\en-US -Force
436411
}
437412

438-
task PackageModule {
439-
[System.IO.Compression.ZipFile]::CreateFromDirectory(
440-
"$PSScriptRoot/module/",
441-
"$PSScriptRoot/PowerShellEditorServices-$($script:FullVersion).zip",
442-
[System.IO.Compression.CompressionLevel]::Optimal,
443-
$false)
444-
}
445-
446-
task UploadArtifacts -If ($null -ne $env:TF_BUILD) {
447-
Copy-Item -Path .\PowerShellEditorServices-$($script:FullVersion).zip -Destination $env:BUILD_ARTIFACTSTAGINGDIRECTORY -Force
448-
}
449-
450413
# The default task is to run the entire CI build
451-
task . GetProductVersion, Clean, Build, Test, BuildCmdletHelp, PackageModule, UploadArtifacts
414+
task . Clean, Build, Test, BuildCmdletHelp
File renamed without changes.

0 commit comments

Comments
 (0)