From a56a7a91eaf8cb6333add1304b584911eefe4619 Mon Sep 17 00:00:00 2001 From: Gang Wang Date: Thu, 20 Feb 2025 06:14:49 +0000 Subject: [PATCH 1/2] Add the check on version bump up --- .vsts-dotnet-ci.yml | 35 +++++++++++++++++++++++++++++++++++ eng/Versions.props | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.vsts-dotnet-ci.yml b/.vsts-dotnet-ci.yml index d538f655a85..58d80bffcd3 100644 --- a/.vsts-dotnet-ci.yml +++ b/.vsts-dotnet-ci.yml @@ -4,6 +4,41 @@ 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*\d+\.\d+\.\d+<\/VersionPrefix>%.*\+\s*\d+\.\d+\.\d+<\/VersionPrefix>release<\/DotNetFinalVersionKind>' + $isInitialCommit = $changedContent -match $initialCommitPattern + $pattern = '-\s*\d+\.\d+\.(?\d+)<\/VersionPrefix>.*%\+\s*\d+\.\d+\.(?\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: BootstrapMSBuildOnFullFrameworkWindows displayName: "Windows Full" pool: diff --git a/eng/Versions.props b/eng/Versions.props index 3938f8bbdd6..ee53a3bfc68 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -2,7 +2,7 @@ - 17.8.21 + 17.8.22 release 17.7.0 15.1.0.0 From 88e27bf6edac7d092a9cb11f1e639cae1c60edec Mon Sep 17 00:00:00 2001 From: YuliiaKovalova <95473390+YuliiaKovalova@users.noreply.github.com> Date: Thu, 3 Apr 2025 11:09:02 +0200 Subject: [PATCH 2/2] Add condition to CheckVersionBumpOnReleaseBranches job --- .vsts-dotnet-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.vsts-dotnet-ci.yml b/.vsts-dotnet-ci.yml index 58d80bffcd3..b999b6fd978 100644 --- a/.vsts-dotnet-ci.yml +++ b/.vsts-dotnet-ci.yml @@ -5,6 +5,7 @@ trigger: jobs: - job: CheckVersionBumpOnReleaseBranches + condition: startsWith(variables['System.PullRequest.TargetBranch'], 'vs') displayName: "Check Version Bump On Release Branches" steps: - powershell: |