Skip to content

[vs17.10] Check version bump on release branches' update #10041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .vsts-dotnet-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,43 @@ trigger:
- vs*

jobs:
- job: CheckVersionBumpOnReleaseBranches
displayName: "Check Version Bump On Release Branches"
steps:
- powershell: |
$versionsFile = "eng/Versions.props"
$changedFiles = git diff --name-only HEAD HEAD~1
$changedVersionsFile = $changedFiles | Where-Object { $_ -eq $versionsFile }
$isInitialCommit = $false
$isVersionBumped = $false
if ($changedVersionsFile -ne $null) {
$difference = git diff HEAD~1 $versionsFile
$changedContent = $difference -join " "
# 'DotNetFinalVersionKind' is expected to be added only during the initial setup of the release branch
$initialCommitPattern = '-\s*<VersionPrefix>\d+\.\d+\.\d+<\/VersionPrefix> \+\s*<VersionPrefix>\d+\.\d+\.\d+<\/VersionPrefix>.*<DotNetFinalVersionKind>release<\/DotNetFinalVersionKind>'
$isInitialCommit = $changedContent -match $initialCommitPattern
$pattern = '-\s*<VersionPrefix>\d+\.\d+\.(?<previous>\d+)<\/VersionPrefix>.* \+\s*<VersionPrefix>\d+\.\d+\.(?<current>\d+)<\/VersionPrefix>'
if (!($isInitialCommit) -and ($changedContent -match $pattern)) {
try {
$previousPatch = [Convert]::ToInt32($Matches.previous)
$currentPatch = [Convert]::ToInt32($Matches.current)
if ($currentPatch -gt $previousPatch) {
$isVersionBumped = $true
}
} catch {
Write-Host "An error occurred during conversion: $_"
}
}
}

if (!($isInitialCommit -or $isVersionBumped)) {
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."
}
condition: startsWith(variables['System.PullRequest.TargetBranch'], 'vs')
displayName: "Check if patch version is bumped up"

- job: IfOnlyDocumentionChanged
dependsOn: CheckVersionBumpOnReleaseBranches
displayName: "Check whether Test Results need to be executed"
steps:
- powershell: |
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- 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. -->
<Project>
<PropertyGroup>
<VersionPrefix>17.10.4</VersionPrefix><DotNetFinalVersionKind>release</DotNetFinalVersionKind>
<VersionPrefix>17.10.5</VersionPrefix><DotNetFinalVersionKind>release</DotNetFinalVersionKind>
<PackageValidationBaselineVersion>17.8.3</PackageValidationBaselineVersion>
<AssemblyVersion>15.1.0.0</AssemblyVersion>
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>
Expand Down