Skip to content

Commit 77d9c2f

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 4d3217e commit 77d9c2f

File tree

4 files changed

+121
-62
lines changed

4 files changed

+121
-62
lines changed

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

Lines changed: 65 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,72 @@ 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+
stages:
30+
- Build
31+
- Sign
32+
33+
stages:
34+
- stage: Build
35+
displayName: Build the release
36+
jobs:
37+
- job: Build
38+
pool:
39+
vmImage: windows-2019
40+
steps:
41+
- template: templates/ci-general.yml
42+
parameters:
43+
usePipelineArtifact: true
44+
45+
- stage: Sign
46+
displayName: Sign the release
47+
jobs:
48+
- job: Sign
49+
pool:
50+
name: 1ES
51+
demands: ImageOverride -equals MMS2019
52+
variables:
53+
- group: ESRP
54+
steps:
55+
- template: templates/release-general.yml
56+
57+
- stage: PublishGitHub
58+
displayName: Publish the draft release
59+
jobs:
60+
- deployment: Publish
61+
environment: vscode-powershell-github
62+
pool:
63+
vmImage: ubuntu-latest
64+
variables:
65+
- group: Publish
66+
strategy:
67+
runOnce:
68+
deploy:
69+
steps:
70+
- template: templates/publish-github.yml
71+
72+
- stage: PublishMarkets
73+
displayName: Publish to marketplace and gallery
74+
jobs:
75+
- deployment: Publish
76+
environment: vscode-powershell-markets
77+
pool:
78+
vmImage: ubuntu-latest
79+
variables:
80+
- group: Publish
81+
strategy:
82+
runOnce:
83+
deploy:
84+
steps:
85+
- 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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
steps:
2+
- checkout: self
3+
4+
- download: current
5+
artifact: vscode-powershell
6+
displayName: Download signed artifacts
7+
8+
- pwsh: |
9+
vsce publish --packagePath $(Pipeline.Workspace)/powershell-*.vsix --pat $(VsceToken)
10+
displayName: Publishing VSIX to VS Code Marketplace
11+
12+
# NOTE: We rarely update this script, so we can ignore errors from the gallery
13+
# caused by us trying to re-publish an updated script.
14+
- pwsh: |
15+
Publish-Script -Path $(Pipeline.Workspace)/Install-VSCode.ps1 -ErrorAction Continue -NuGetApiKey $(GalleryToken)
16+
displayName: Publishing Install-VSCode.ps1 to PowerShell Gallery
Lines changed: 29 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,51 @@
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

7+
# NOTE: The signing templates explicitly copy everything along as they run, so
8+
# the last output path has every signed (and intentionally unsigned) file.
349
- template: EsrpSign.yml@ComplianceRepo
3510
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
11+
buildOutputPath: $(Pipeline.Workspace)/vscode-powershell-unsigned-script
12+
signOutputPath: $(Pipeline.Workspace)/signed
13+
alwaysCopy: true
14+
certificateId: CP-230012 # Authenticode certificate
4115
shouldSign: true # We always want to sign
4216
# NOTE: Code AKA *.vsix files are not signed
43-
pattern: |
44-
Install-VSCode.ps1
17+
pattern: Install-VSCode.ps1
18+
19+
# NOTE: Because the scan template doesn't copy (unlike the sign template), we do
20+
# it ourselves so that we can publish one finished artifact.
21+
- task: CopyFiles@2
22+
inputs:
23+
sourceFolder: $(Pipeline.Workspace)/vscode-powershell-vsix
24+
targetFolder: $(Pipeline.Workspace)/signed
4525

4626
- template: EsrpScan.yml@ComplianceRepo
4727
parameters:
48-
scanPath: $(Build.ArtifactStagingDirectory)/Signed
49-
pattern: |
50-
*.vsix
28+
scanPath: $(Pipeline.Workspace)/signed
29+
pattern: powershell-*.vsix
5130

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

5633
- template: script-module-compliance.yml@ComplianceRepo
5734
parameters:
5835
# component-governance
59-
sourceScanPath: '$(Build.SourcesDirectory)/vscode-powershell'
36+
sourceScanPath: $(Build.SourcesDirectory)/vscode-powershell
6037
# credscan
61-
suppressionsFile: '$(Build.SourcesDirectory)/vscode-powershell/tools/credScan/suppress.json'
38+
suppressionsFile: $(Build.SourcesDirectory)/vscode-powershell/tools/credScan/suppress.json
6239
# TermCheck AKA PoliCheck
63-
targetArgument: '$(Build.SourcesDirectory)/vscode-powershell'
64-
optionsUEPATH: '$(Build.SourcesDirectory)/vscode-powershell/tools/terms/UserExclusions.xml'
40+
targetArgument: $(Build.SourcesDirectory)/vscode-powershell
41+
optionsUEPATH: $(Build.SourcesDirectory)/vscode-powershell/tools/terms/UserExclusions.xml
6542
optionsRulesDBPath: ''
66-
optionsFTPath: '$(Build.SourcesDirectory)/vscode-powershell/tools/terms/FileTypeSet.xml'
43+
optionsFTPath: $(Build.SourcesDirectory)/vscode-powershell/tools/terms/FileTypeSet.xml
6744
# tsa-upload
68-
codeBaseName: 'PowerShell_PowerShellEditorServices_20210201'
45+
codeBaseName: PowerShell_PowerShellEditorServices_20210201
6946
# We don't use any Windows APIs directly, so we don't need API scan
7047
APIScan: false
48+
49+
- publish: $(Pipeline.Workspace)/signed
50+
artifact: vscode-powershell
51+
displayName: Publish signed artifacts

0 commit comments

Comments
 (0)