Skip to content

Commit 4da48af

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 4792107 commit 4da48af

File tree

4 files changed

+27
-67
lines changed

4 files changed

+27
-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-$(System.JobId)
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
+15-24
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
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+
displayName: Download unsigned pipeline artifacts
145

156
- checkout: ComplianceRepo
167

178
# NOTE: The signing templates explicitly copy everything along as they run, so
189
# the last output path has every signed (and intentionally unsigned) file.
1910
- template: EsrpSign.yml@ComplianceRepo
2011
parameters:
21-
buildOutputPath: $(Build.ArtifactStagingDirectory)/Unsigned
22-
signOutputPath: $(Build.ArtifactStagingDirectory)/FirstPartySigned
12+
buildOutputPath: $(Pipeline.Workspace)/PowerShellEditorServices-Build-*
13+
signOutputPath: $(Pipeline.Workspace)/FirstPartySigned
2314
alwaysCopy: true
2415
certificateId: CP-230012 # Authenticode certificate
2516
shouldSign: true # We always want to sign
@@ -37,8 +28,8 @@ steps:
3728
3829
- template: EsrpSign.yml@ComplianceRepo
3930
parameters:
40-
buildOutputPath: $(Build.ArtifactStagingDirectory)/FirstPartySigned
41-
signOutputPath: $(Build.ArtifactStagingDirectory)/ThirdPartySigned
31+
buildOutputPath: $(Pipeline.Workspace)/FirstPartySigned
32+
signOutputPath: $(Pipeline.Workspace)/ThirdPartySigned
4233
alwaysCopy: true
4334
certificateId: CP-231522 # Third-party certificate
4435
shouldSign: true # We always want to sign
@@ -54,14 +45,14 @@ steps:
5445
- task: ArchiveFiles@2
5546
displayName: Zip finished assets
5647
inputs:
57-
rootFolderOrFile: $(Build.ArtifactStagingDirectory)/ThirdPartySigned
48+
rootFolderOrFile: $(Pipeline.Workspace)/ThirdPartySigned
5849
includeRootFolder: false
5950
archiveType: zip
60-
archiveFile: $(Build.ArtifactStagingDirectory)/PowerShellEditorServices.zip
51+
archiveFile: PowerShellEditorServices.zip
6152
replaceExistingArchive: true
6253
verbose: true
6354

64-
- publish: $(Build.ArtifactStagingDirectory)/PowerShellEditorServices.zip
55+
- publish: PowerShellEditorServices.zip
6556
artifact: PowerShellEditorServices
6657
displayName: Publish signed pipeline artifacts
6758

@@ -70,18 +61,18 @@ steps:
7061
- template: assembly-module-compliance.yml@ComplianceRepo
7162
parameters:
7263
# binskim
73-
AnalyzeTarget: '$(Build.ArtifactStagingDirectory)/*.dll'
64+
AnalyzeTarget: $(Pipeline.Workspace)/*.dll
7465
AnalyzeSymPath: 'SRV*'
7566
# component-governance
76-
sourceScanPath: '$(Build.SourcesDirectory)/PowerShellEditorServices'
67+
sourceScanPath: $(Build.SourcesDirectory)/PowerShellEditorServices
7768
# credscan
7869
suppressionsFile: ''
7970
# TermCheck AKA PoliCheck
80-
targetArgument: '$(Build.SourcesDirectory)/PowerShellEditorServices'
81-
optionsUEPATH: '$(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/UserExclusions.xml'
71+
targetArgument: $(Build.SourcesDirectory)/PowerShellEditorServices
72+
optionsUEPATH: $(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/UserExclusions.xml
8273
optionsRulesDBPath: ''
83-
optionsFTPath: '$(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/FileTypeSet.xml'
74+
optionsFTPath: $(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/FileTypeSet.xml
8475
# tsa-upload
85-
codeBaseName: 'PowerShell_PowerShellEditorServices_20210201'
76+
codeBaseName: PowerShell_PowerShellEditorServices_20210201
8677
# selections
8778
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)