Skip to content

Commit 35704b8

Browse files
committed
Pipeline-ify release process
This sets up the Azure DevOps release pipeline to not only build, test, and sign the bits for a release (and to do so using signed PowerShellEditorServices bits), but to automatically create the GitHub draft release where it directly uploads the artifacts. After manual approval, it will automatically publish the extension and installation script to their respective registries (the Visual Studio Code marketplace and the PowerShell Gallery). Best of all, this process is kicked off automatically after a successful release build of PowerShellEditorServices.
1 parent a987d4d commit 35704b8

File tree

4 files changed

+117
-62
lines changed

4 files changed

+117
-62
lines changed

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

Lines changed: 64 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,71 @@ resources:
1414
repositories:
1515
- repository: ComplianceRepo
1616
type: github
17-
endpoint: ComplianceGHRepo
17+
endpoint: GitHub
1818
name: PowerShell/Compliance
19+
20+
- repository: PowerShellEditorServices
21+
type: git
22+
name: PowerShellEditorServices
23+
ref: release
24+
1925
pipelines:
2026
- pipeline: PowerShellEditorServices
2127
source: PowerShellEditorServices
22-
trigger: true
23-
24-
25-
jobs:
26-
- job: 'ReleaseBuild'
27-
displayName: 'Build release'
28-
pool:
29-
name: '1ES'
30-
demands: ImageOverride -equals MMS2019
31-
variables:
32-
- group: ESRP
33-
steps:
34-
- template: templates/release-general.yml
28+
trigger:
29+
branches:
30+
- release
31+
32+
stages:
33+
- stage: Build
34+
displayName: Build the release
35+
jobs:
36+
- job: Build
37+
pool:
38+
vmImage: windows-2019
39+
steps:
40+
- template: templates/ci-general.yml
41+
parameters:
42+
usePipelineArtifact: true
43+
44+
- stage: Sign
45+
displayName: Sign the release
46+
jobs:
47+
- job: Sign
48+
pool:
49+
name: 1ES
50+
demands: ImageOverride -equals MMS2019
51+
variables:
52+
- group: ESRP
53+
steps:
54+
- template: templates/release-general.yml
55+
56+
- stage: PublishGitHub
57+
displayName: Publish the draft release
58+
jobs:
59+
- deployment: Publish
60+
environment: vscode-powershell-github
61+
pool:
62+
vmImage: ubuntu-latest
63+
variables:
64+
- group: Publish
65+
strategy:
66+
runOnce:
67+
deploy:
68+
steps:
69+
- template: templates/publish-github.yml
70+
71+
- stage: PublishMarkets
72+
displayName: Publish to marketplace and gallery
73+
jobs:
74+
- deployment: Publish
75+
environment: vscode-powershell-markets
76+
pool:
77+
vmImage: ubuntu-latest
78+
variables:
79+
- group: Publish
80+
strategy:
81+
runOnce:
82+
deploy:
83+
steps:
84+
- template: templates/publish-markets.yml

.vsts-ci/templates/publish-github.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
steps:
2+
- checkout: self
3+
4+
- download: current
5+
artifact: vscode-powershell
6+
displayName: Download signed artifacts
7+
8+
- pwsh: |
9+
$(Build.SourcesDirectory)/tools/setupReleaseTools.ps1 -Token $(GitHubToken)
10+
New-DraftRelease -RepositoryName vscode-powershell -Assets $(Pipeline.Workspace)/vscode-powershell/powershell-*.vsix,$(Pipeline.Workspace)/vscode-powershell/Install-VSCode.ps1
11+
displayName: Drafting a GitHub Release
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
steps:
2+
- checkout: self
3+
4+
- download: current
5+
artifact: vscode-powershell
6+
displayName: Download signed artifacts
7+
8+
- pwsh: |
9+
npm install -g vsce
10+
vsce publish --packagePath $(Pipeline.Workspace)/powershell-*.vsix --pat $(VsceToken)
11+
displayName: Publishing VSIX to VS Code Marketplace
12+
13+
# NOTE: We rarely update this script, so we can ignore errors from the gallery
14+
# caused by us trying to re-publish an updated script.
15+
- pwsh: |
16+
Publish-Script -Path $(Pipeline.Workspace)/Install-VSCode.ps1 -ErrorAction Continue -NuGetApiKey $(GalleryToken)
17+
displayName: Publishing Install-VSCode.ps1 to PowerShell Gallery
Lines changed: 25 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,47 @@
11
steps:
2-
- checkout: self
3-
4-
- pwsh: |
5-
Get-ChildItem -Path env:
6-
displayName: Capture environment
7-
condition: succeededOrFailed()
8-
9-
- task: DownloadPipelineArtifact@2
10-
displayName: 'Download Artifacts from PowerShellEditorServices'
11-
inputs:
12-
source: specific
13-
project: 'PowerShellEditorServices'
14-
pipeline: 36
15-
preferTriggeringPipeline: true
16-
allowPartiallySucceededBuilds: true
17-
artifact: 'PowerShellEditorServices'
18-
path: '$(Build.SourcesDirectory)/PowerShellEditorServices/module/'
19-
20-
- pwsh: |
21-
New-Item -ItemType Directory $(Build.ArtifactStagingDirectory)/vscode-powershell
22-
Install-Module InvokeBuild -Force
23-
Invoke-Build Release
24-
workingDirectory: '$(Build.SourcesDirectory)/vscode-powershell'
25-
26-
- task: PublishTestResults@2
27-
inputs:
28-
testRunner: JUnit
29-
testResultsFiles: '**/test-results.xml'
30-
condition: succeededOrFailed()
2+
- download: current
3+
displayName: Download pipeline artifacts
314

325
- checkout: ComplianceRepo
336

347
- template: EsrpSign.yml@ComplianceRepo
358
parameters:
36-
buildOutputPath: '$(Build.ArtifactStagingDirectory)/vscode-powershell'
37-
signOutputPath: '$(Build.ArtifactStagingDirectory)/Signed'
38-
alwaysCopy: true # So publishing works
39-
certificateId: 'CP-230012' # Authenticode certificate
40-
useMinimatch: true # This enables the use of globbing
9+
buildOutputPath: $(Pipeline.Workspace)/vscode-powershell-unsigned-script-*
10+
signOutputPath: $(Pipeline.Workspace)/signed
11+
alwaysCopy: true
12+
certificateId: CP-230012 # Authenticode certificate
4113
shouldSign: true # We always want to sign
4214
# NOTE: Code AKA *.vsix files are not signed
43-
pattern: |
44-
Install-VSCode.ps1
15+
pattern: Install-VSCode.ps1
16+
17+
# NOTE: Because the scan template doesn't copy (unlike the sign template), we do
18+
# it ourselves so that we can publish one finished artifact.
19+
- pwsh: Copy-Item -Path $(Pipeline.Workspace)/vscode-powershell-vsix-*/*.vsix -Destination $(Pipeline.Workspace)/signed -Verbose
20+
displayName: Copy extension to signed folder
4521

4622
- template: EsrpScan.yml@ComplianceRepo
4723
parameters:
48-
scanPath: $(Build.ArtifactStagingDirectory)/Signed
49-
pattern: |
50-
*.vsix
24+
scanPath: $(Pipeline.Workspace)/signed
25+
pattern: powershell-*.vsix
5126

52-
- publish: $(Build.ArtifactStagingDirectory)/Signed
53-
artifact: vscode-powershell
54-
displayName: 'Publish signed (and unsigned) artifacts'
27+
- checkout: self
5528

5629
- template: script-module-compliance.yml@ComplianceRepo
5730
parameters:
5831
# component-governance
59-
sourceScanPath: '$(Build.SourcesDirectory)/vscode-powershell'
32+
sourceScanPath: $(Build.SourcesDirectory)/vscode-powershell
6033
# credscan
61-
suppressionsFile: '$(Build.SourcesDirectory)/vscode-powershell/tools/credScan/suppress.json'
34+
suppressionsFile: $(Build.SourcesDirectory)/vscode-powershell/tools/credScan/suppress.json
6235
# TermCheck AKA PoliCheck
63-
targetArgument: '$(Build.SourcesDirectory)/vscode-powershell'
64-
optionsUEPATH: '$(Build.SourcesDirectory)/vscode-powershell/tools/terms/UserExclusions.xml'
36+
targetArgument: $(Build.SourcesDirectory)/vscode-powershell
37+
optionsUEPATH: $(Build.SourcesDirectory)/vscode-powershell/tools/terms/UserExclusions.xml
6538
optionsRulesDBPath: ''
66-
optionsFTPath: '$(Build.SourcesDirectory)/vscode-powershell/tools/terms/FileTypeSet.xml'
39+
optionsFTPath: $(Build.SourcesDirectory)/vscode-powershell/tools/terms/FileTypeSet.xml
6740
# tsa-upload
68-
codeBaseName: 'PowerShell_PowerShellEditorServices_20210201'
41+
codeBaseName: PowerShell_PowerShellEditorServices_20210201
6942
# We don't use any Windows APIs directly, so we don't need API scan
7043
APIScan: false
44+
45+
- publish: $(Pipeline.Workspace)/signed
46+
artifact: vscode-powershell
47+
displayName: Publish signed artifacts

0 commit comments

Comments
 (0)