Skip to content

Commit a590493

Browse files
committed
Use pipeline artifacts instead of build artifacts
Also move the creation of said artifacts into Azure DevOps templates themselves, instead of in the build system. Finally, download only the signed pipeline artifacts in the deployment, which by default downloads all artifacts.
1 parent ab4acbf commit a590493

File tree

4 files changed

+28
-67
lines changed

4 files changed

+28
-67
lines changed

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,25 @@ steps:
2222
- pwsh: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
2323
displayName: Set Build Name for Non-PR
2424
condition: ne(variables['Build.Reason'], 'PullRequest')
25+
2526
- task: PowerShell@2
2627
inputs:
2728
filePath: tools/azurePipelinesBuild.ps1
2829
pwsh: ${{ parameters.pwsh }}
30+
31+
- publish: module
32+
artifact: PowerShellEditorServices-Build
33+
displayName: Publish unsigned pipeline artifacts
34+
condition: succeededOrFailed()
35+
2936
- task: PublishTestResults@2
3037
inputs:
3138
testRunner: VSTest
3239
testResultsFiles: '**/*.trx'
3340
condition: succeededOrFailed()
41+
3442
- task: PublishTestResults@2
3543
inputs:
3644
testRunner: NUnit
3745
testResultsFiles: '**/TestResults.xml'
3846
condition: succeededOrFailed()
39-
- task: PublishBuildArtifacts@1
40-
inputs:
41-
ArtifactName: PowerShellEditorServices-CI
42-
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
43-
condition: succeededOrFailed()

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

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
steps:
22
- checkout: self
33
- checkout: vscode-powershell
4+
- download: current
5+
artifact: PowerShellEditorServices
6+
displayName: Download signed pipeline artifacts
47
- pwsh: |
58
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null
69
Install-Module -Name PowerShellForGitHub -Scope CurrentUser -Force -Confirm:$false
+16-24
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
steps:
22

3-
# TODO: Replace build artifacts with pipeline artifacts
4-
- task: DownloadBuildArtifacts@0
5-
displayName: Download build artifacts
6-
inputs:
7-
downloadType: specific
8-
9-
- task: ExtractFiles@1
10-
displayName: Unzip build artifacts
11-
inputs:
12-
archiveFilePatterns: $(Build.ArtifactStagingDirectory)/PowerShellEditorServices-CI/PowerShellEditorServices*.zip
13-
destinationFolder: $(Build.ArtifactStagingDirectory)/Unsigned
3+
- download: current
4+
artifact: PowerShellEditorServices-Build
5+
displayName: Download unsigned pipeline artifacts
146

157
- checkout: ComplianceRepo
168

179
# NOTE: The signing templates explicitly copy everything along as they run, so
1810
# the last output path has every signed (and intentionally unsigned) file.
1911
- template: EsrpSign.yml@ComplianceRepo
2012
parameters:
21-
buildOutputPath: $(Build.ArtifactStagingDirectory)/Unsigned
22-
signOutputPath: $(Build.ArtifactStagingDirectory)/FirstPartySigned
13+
buildOutputPath: $(Pipeline.Workspace)/PowerShellEditorServices-Build
14+
signOutputPath: $(Pipeline.Workspace)/FirstPartySigned
2315
alwaysCopy: true
2416
certificateId: CP-230012 # Authenticode certificate
2517
shouldSign: true # We always want to sign
@@ -37,8 +29,8 @@ steps:
3729
3830
- template: EsrpSign.yml@ComplianceRepo
3931
parameters:
40-
buildOutputPath: $(Build.ArtifactStagingDirectory)/FirstPartySigned
41-
signOutputPath: $(Build.ArtifactStagingDirectory)/ThirdPartySigned
32+
buildOutputPath: $(Pipeline.Workspace)/FirstPartySigned
33+
signOutputPath: $(Pipeline.Workspace)/ThirdPartySigned
4234
alwaysCopy: true
4335
certificateId: CP-231522 # Third-party certificate
4436
shouldSign: true # We always want to sign
@@ -54,14 +46,14 @@ steps:
5446
- task: ArchiveFiles@2
5547
displayName: Zip finished assets
5648
inputs:
57-
rootFolderOrFile: $(Build.ArtifactStagingDirectory)/ThirdPartySigned
49+
rootFolderOrFile: $(Pipeline.Workspace)/ThirdPartySigned
5850
includeRootFolder: false
5951
archiveType: zip
60-
archiveFile: $(Build.ArtifactStagingDirectory)/PowerShellEditorServices.zip
52+
archiveFile: PowerShellEditorServices.zip
6153
replaceExistingArchive: true
6254
verbose: true
6355

64-
- publish: $(Build.ArtifactStagingDirectory)/PowerShellEditorServices.zip
56+
- publish: PowerShellEditorServices.zip
6557
artifact: PowerShellEditorServices
6658
displayName: Publish signed pipeline artifacts
6759

@@ -70,18 +62,18 @@ steps:
7062
- template: assembly-module-compliance.yml@ComplianceRepo
7163
parameters:
7264
# binskim
73-
AnalyzeTarget: '$(Build.ArtifactStagingDirectory)/*.dll'
65+
AnalyzeTarget: $(Pipeline.Workspace)/*.dll
7466
AnalyzeSymPath: 'SRV*'
7567
# component-governance
76-
sourceScanPath: '$(Build.SourcesDirectory)/PowerShellEditorServices'
68+
sourceScanPath: $(Build.SourcesDirectory)/PowerShellEditorServices
7769
# credscan
7870
suppressionsFile: ''
7971
# TermCheck AKA PoliCheck
80-
targetArgument: '$(Build.SourcesDirectory)/PowerShellEditorServices'
81-
optionsUEPATH: '$(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/UserExclusions.xml'
72+
targetArgument: $(Build.SourcesDirectory)/PowerShellEditorServices
73+
optionsUEPATH: $(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/UserExclusions.xml
8274
optionsRulesDBPath: ''
83-
optionsFTPath: '$(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/FileTypeSet.xml'
75+
optionsFTPath: $(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/FileTypeSet.xml
8476
# tsa-upload
85-
codeBaseName: 'PowerShell_PowerShellEditorServices_20210201'
77+
codeBaseName: PowerShell_PowerShellEditorServices_20210201
8678
# selections
8779
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

0 commit comments

Comments
 (0)