Skip to content

Commit 3c1a090

Browse files
committed
Fix writing version to file
1 parent ebebc7a commit 3c1a090

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

azure-pipelines.yml

+6-15
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,17 @@ jobs:
3535
vmImage: 'windows-latest'
3636
steps:
3737
- template: ci/testing.yml
38-
39-
# Add a new job for version bumping when develop is merged to main
38+
4039
- job: version_bump
4140
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
4241
pool:
4342
vmImage: 'windows-latest'
43+
dependsOn:
44+
testing
4445
steps:
4546
- checkout: self
4647
persistCredentials: true
4748

48-
- powershell: |
49-
# Check if this is a merge from develop to main
50-
$commitMessage = git log --format=%B -n 1 $(Build.SourceVersion)
51-
if ($commitMessage -match "Merge.*develop") {
52-
Write-Host "##vso[task.setvariable variable=IsMergeFromDevelop]true"
53-
} else {
54-
Write-Host "##vso[task.setvariable variable=IsMergeFromDevelop]false"
55-
}
56-
displayName: 'Check if merge from develop'
57-
5849
- powershell: |
5950
# Find version file (could be Directory.Build.props, .csproj, or AssemblyInfo.cs)
6051
# This example assumes Directory.Build.props
@@ -70,7 +61,7 @@ jobs:
7061
7162
# Read current version
7263
$fileContent = Get-Content $versionFile -Raw
73-
if ($fileContent -match '<Version>(.*?)</Version>') {
64+
if ($fileContent -match '<Version>(.*?)</AssemblyVersion>') {
7465
$currentVersion = $matches[1]
7566
Write-Host "Current version: $currentVersion"
7667
@@ -95,7 +86,8 @@ jobs:
9586
Write-Host "New version: $newVersion"
9687
9788
# Update version in file
98-
$fileContent = $fileContent -replace '<Version>(.*?)</Version>', "<Version>$newVersion</Version>"
89+
$fileContent = $fileContent -replace '<AssemblyVersion>(.*?)</AssemblyVersion>', "<AssemblyVersion>$newVersion</AssemblyVersion>"
90+
$fileContent = $fileContent -replace '<FileVersion>(.*?)</FileVersion>', "<FileVersion>$newVersion</FileVersion>"
9991
Set-Content -Path $versionFile -Value $fileContent
10092
10193
# Set version number as build variable
@@ -123,7 +115,6 @@ jobs:
123115
Write-Host "##vso[task.logissue type=warning]No version tag found in $versionFile"
124116
}
125117
displayName: 'Bump patch version'
126-
condition: eq(variables['IsMergeFromDevelop'], 'true')
127118
env:
128119
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
129120

0 commit comments

Comments
 (0)