-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathazure-pipelines.yml
127 lines (104 loc) · 4.41 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
trigger:
- main
- develop
pr: none
variables:
solution: 'OSDP-Bench.sln'
buildConfiguration: 'Release'
outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'
buildPlatform: 'x64|ARM64'
appxPackageDir: '$(build.artifactStagingDirectory)\AppxPackages\\'
jobs:
#- job: android_build
# pool:
# vmImage: 'windows-latest'
# steps:
# - template: ci/android-build.yml
#- job: winui_build
# pool:
# vmImage: 'windows-latest'
# steps:
# - template: ci/winui-build.yml
- job: testing
pool:
vmImage: 'windows-latest'
steps:
- template: ci/testing.yml
- job: version_bump
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
pool:
vmImage: 'windows-latest'
dependsOn:
testing
steps:
- checkout: self
persistCredentials: true
- powershell: |
# Find version file (could be Directory.Build.props, .csproj, or AssemblyInfo.cs)
# This example assumes Directory.Build.props
$versionFile = "Directory.Build.props"
if (Test-Path $versionFile) {
Write-Host "Using $versionFile for version"
} else {
# Try to find the main project file
$versionFile = Get-ChildItem -Path . -Filter "*.csproj" -Recurse | Select-Object -First 1 -ExpandProperty FullName
Write-Host "Using $versionFile for version"
}
# Read current version
$fileContent = Get-Content $versionFile -Raw
if ($fileContent -match '<AssemblyVersion>(.*?)</AssemblyVersion>') {
$currentVersion = $matches[1]
Write-Host "Current version: $currentVersion"
# Parse version components
$versionParts = $currentVersion.Split('.')
$major = $versionParts[0]
$minor = $versionParts[1]
$patch = [int]$versionParts[2]
$build = $versionParts[3]
# Increment patch number instead of build number
$patch++
# Keep build number if it exists, otherwise just use major.minor.patch
if ($versionParts.Length -gt 3) {
$build = $versionParts[3]
$newVersion = "$major.$minor.$patch.$build"
} else {
$newVersion = "$major.$minor.$patch"
}
Write-Host "New version: $newVersion"
# Update version in file
$fileContent = $fileContent -replace '<AssemblyVersion>(.*?)</AssemblyVersion>', "<AssemblyVersion>$newVersion</AssemblyVersion>"
$fileContent = $fileContent -replace '<FileVersion>(.*?)</FileVersion>', "<FileVersion>$newVersion</FileVersion>"
Set-Content -Path $versionFile -Value $fileContent
# Set version number as build variable
Write-Host "##vso[task.setvariable variable=BuildVersion]$newVersion"
# Configure git
git config user.email "[email protected]"
git config user.name "Azure DevOps Pipeline"
# Commit and push changes
git add $versionFile
git commit -m "Bump version to $newVersion [skip ci]"
# Set remote url with credentials
$accessToken = "$(System.AccessToken)"
$repoUrl = "$(Build.Repository.Uri)"
# Remove the 'https://' prefix and add the PAT
$repoUrl = $repoUrl -replace "https://", "https://`:$accessToken@"
git push $repoUrl HEAD:main
Write-Host "Version bumped to $newVersion"
} else {
Write-Host "##vso[task.logissue type=warning]No version tag found in $versionFile"
}
displayName: 'Bump patch version'
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
# Update build number with the version we just set
- powershell: |
# Set the build number to the version
if ("$(BuildVersion)" -ne "") {
Write-Host "##vso[build.updatebuildnumber]$(BuildVersion)"
}
displayName: 'Update build number'
condition: and(succeeded(), ne(variables['BuildVersion'], ''))