Skip to content

Commit eeea1e8

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 eeea1e8

File tree

4 files changed

+28
-66
lines changed

4 files changed

+28
-66
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
+16-23
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
steps:
22

3-
# TODO: Replace build artifacts with pipeline artifacts
4-
- task: DownloadBuildArtifacts@0
5-
displayName: Download build artifacts
3+
- task: DownloadPipelineArtifact@2
64
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
5+
path: PowerShellEditorServices-Build
6+
displayName: Download unsigned pipeline artifacts
147

158
- checkout: ComplianceRepo
169

1710
# NOTE: The signing templates explicitly copy everything along as they run, so
1811
# the last output path has every signed (and intentionally unsigned) file.
1912
- template: EsrpSign.yml@ComplianceRepo
2013
parameters:
21-
buildOutputPath: $(Build.ArtifactStagingDirectory)/Unsigned
22-
signOutputPath: $(Build.ArtifactStagingDirectory)/FirstPartySigned
14+
buildOutputPath: $(Pipeline.Workspace)/PowerShellEditorServices-Build
15+
signOutputPath: $(Pipeline.Workspace)/FirstPartySigned
2316
alwaysCopy: true
2417
certificateId: CP-230012 # Authenticode certificate
2518
shouldSign: true # We always want to sign
@@ -37,8 +30,8 @@ steps:
3730
3831
- template: EsrpSign.yml@ComplianceRepo
3932
parameters:
40-
buildOutputPath: $(Build.ArtifactStagingDirectory)/FirstPartySigned
41-
signOutputPath: $(Build.ArtifactStagingDirectory)/ThirdPartySigned
33+
buildOutputPath: $(Pipeline.Workspace)/FirstPartySigned
34+
signOutputPath: $(Pipeline.Workspace)/ThirdPartySigned
4235
alwaysCopy: true
4336
certificateId: CP-231522 # Third-party certificate
4437
shouldSign: true # We always want to sign
@@ -54,14 +47,14 @@ steps:
5447
- task: ArchiveFiles@2
5548
displayName: Zip finished assets
5649
inputs:
57-
rootFolderOrFile: $(Build.ArtifactStagingDirectory)/ThirdPartySigned
50+
rootFolderOrFile: $(Pipeline.Workspace)/ThirdPartySigned
5851
includeRootFolder: false
5952
archiveType: zip
60-
archiveFile: $(Build.ArtifactStagingDirectory)/PowerShellEditorServices.zip
53+
archiveFile: PowerShellEditorServices.zip
6154
replaceExistingArchive: true
6255
verbose: true
6356

64-
- publish: $(Build.ArtifactStagingDirectory)/PowerShellEditorServices.zip
57+
- publish: PowerShellEditorServices.zip
6558
artifact: PowerShellEditorServices
6659
displayName: Publish signed pipeline artifacts
6760

@@ -70,18 +63,18 @@ steps:
7063
- template: assembly-module-compliance.yml@ComplianceRepo
7164
parameters:
7265
# binskim
73-
AnalyzeTarget: '$(Build.ArtifactStagingDirectory)/*.dll'
66+
AnalyzeTarget: $(Pipeline.Workspace)/*.dll
7467
AnalyzeSymPath: 'SRV*'
7568
# component-governance
76-
sourceScanPath: '$(Build.SourcesDirectory)/PowerShellEditorServices'
69+
sourceScanPath: $(Build.SourcesDirectory)/PowerShellEditorServices
7770
# credscan
7871
suppressionsFile: ''
7972
# TermCheck AKA PoliCheck
80-
targetArgument: '$(Build.SourcesDirectory)/PowerShellEditorServices'
81-
optionsUEPATH: '$(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/UserExclusions.xml'
73+
targetArgument: $(Build.SourcesDirectory)/PowerShellEditorServices
74+
optionsUEPATH: $(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/UserExclusions.xml
8275
optionsRulesDBPath: ''
83-
optionsFTPath: '$(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/FileTypeSet.xml'
76+
optionsFTPath: $(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/FileTypeSet.xml
8477
# tsa-upload
85-
codeBaseName: 'PowerShell_PowerShellEditorServices_20210201'
78+
codeBaseName: PowerShell_PowerShellEditorServices_20210201
8679
# selections
8780
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)