Skip to content

Commit b46a62a

Browse files
authored
Add the check on version bump up (#11469)
1 parent 1ea6cee commit b46a62a

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

.vsts-dotnet-ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,42 @@ trigger:
44
- vs*
55

66
jobs:
7+
- job: CheckVersionBumpOnReleaseBranches
8+
condition: startsWith(variables['System.PullRequest.TargetBranch'], 'vs')
9+
displayName: "Check Version Bump On Release Branches"
10+
steps:
11+
- powershell: |
12+
$versionsFile = "eng/Versions.props"
13+
$changedFiles = git diff --name-only HEAD HEAD~1
14+
$changedVersionsFile = $changedFiles | Where-Object { $_ -eq $versionsFile }
15+
$isInitialCommit = $false
16+
$isVersionBumped = $false
17+
if ($changedVersionsFile -ne $null) {
18+
$difference = git diff HEAD~1 $versionsFile
19+
$changedContent = $difference -join "%"
20+
# 'DotNetFinalVersionKind' is expected to be added only during the initial setup of the release branch
21+
$initialCommitPattern = '-\s*<VersionPrefix>\d+\.\d+\.\d+<\/VersionPrefix>%.*\+\s*<VersionPrefix>\d+\.\d+\.\d+<\/VersionPrefix><DotNetFinalVersionKind>release<\/DotNetFinalVersionKind>'
22+
$isInitialCommit = $changedContent -match $initialCommitPattern
23+
$pattern = '-\s*<VersionPrefix>\d+\.\d+\.(?<previous>\d+)<\/VersionPrefix>.*%\+\s*<VersionPrefix>\d+\.\d+\.(?<current>\d+)<\/VersionPrefix>'
24+
if (!($isInitialCommit) -and ($changedContent -match $pattern)) {
25+
try {
26+
$previousPatch = [Convert]::ToInt32($Matches.previous)
27+
$currentPatch = [Convert]::ToInt32($Matches.current)
28+
if ($currentPatch -gt $previousPatch) {
29+
$isVersionBumped = $true
30+
}
31+
} catch {
32+
Write-Host "An error occurred during conversion: $_"
33+
}
34+
}
35+
}
36+
37+
if (!($isInitialCommit -or $isVersionBumped)) {
38+
throw "Hello! I noticed that you're targeting one of our servicing branches. You need to increase the revision version number (the last part) of 'VersionPrefix' in eng/Versions.props."
39+
}
40+
condition: startsWith(variables['System.PullRequest.TargetBranch'], 'vs')
41+
displayName: "Check if patch version is bumped up"
42+
743
- job: BootstrapMSBuildOnFullFrameworkWindows
844
displayName: "Windows Full"
945
pool:

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
33
<Project>
44
<PropertyGroup>
5-
<VersionPrefix>17.8.23</VersionPrefix>
5+
<VersionPrefix>17.8.24</VersionPrefix>
66
<DotNetFinalVersionKind>release</DotNetFinalVersionKind>
77
<PackageValidationBaselineVersion>17.7.0</PackageValidationBaselineVersion>
88
<AssemblyVersion>15.1.0.0</AssemblyVersion>

0 commit comments

Comments
 (0)