Skip to content

Commit 0c73cea

Browse files
authored
Set the BuildNumber in the release pipeline (#8060)
1 parent 9fbdb24 commit 0c73cea

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pr:
1818
exclude:
1919
- ./*.md
2020
- .github/*
21+
- azure-pipelines/release.yml
2122

2223
# Run a scheduled build every night on main to run tests against insiders VSCode.
2324
# The variable testVSCodeVersion is set to insiders based on the build reason.

azure-pipelines/release.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,27 @@ extends:
5151
runOnce:
5252
deploy:
5353
steps:
54+
- pwsh: |
55+
$artifactVersion = '$(resources.pipeline.officialBuildCI.runName)'
56+
$artifactBranchName = '$(resources.pipeline.officialBuildCI.sourceBranch)' -replace 'refs/heads/',''
57+
58+
# Set the BuildNumber in the form `# Publish prerelease v2.69.22 #` to improve readability in AzDO
59+
$buildNumberName = "Publish $artifactBranchName $artifactVersion"
60+
if ('${{ parameters.test }}' -eq 'true') {
61+
$buildNumberName = 'Test ' + $buildNumberName
62+
}
63+
64+
# Replace invalid characters
65+
$buildNumberName = $buildNumberName -replace '["/:<>\|?@*]','_'
66+
# Maximum buildnumber length is 255 chars and we are going to add a prefix and suffix so ensure we have space.
67+
if ($buildNumberName.Length -GT 252) {
68+
$buildNumberName = $buildNumberName.Substring(0, 252)
69+
}
70+
# Avoid ever ending the BuildNumber with a `.` by always appending to it.
71+
$buildNumberName = ' ' + $buildNumberName + ' #'
72+
73+
Write-Host "##vso[build.updatebuildnumber]$buildNumberName"
74+
displayName: Set BuildNumber
5475
- template: /azure-pipelines/install-node.yml@self
5576
- pwsh: |
5677
npm install --global @vscode/vsce
@@ -113,6 +134,7 @@ extends:
113134
Write-Host "##[command]vsce $publishArgs"
114135
vsce @publishArgs
115136
}
137+
116138
- stage: 'TagRelease'
117139
displayName: 'Tag release of vscode-csharp'
118140
dependsOn: 'PublishStage'

0 commit comments

Comments
 (0)