This repository was archived by the owner on Jul 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathincrementMinorVersion.ps1
More file actions
41 lines (35 loc) · 1.52 KB
/
Copy pathincrementMinorVersion.ps1
File metadata and controls
41 lines (35 loc) · 1.52 KB
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
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
<#
.Synopsis
Increment the minor version string in the gradle.properties if the major,
minor, or patch version hasn't been manually updated.
.Description
Assumptions:
This script assumes it is run from the repo root.
Minor version is typically auto-incremented.
#>
function Update-TelemetryVersion([string]$telemetryFilePath, [version]$version) {
$telemetryFileContent = Get-Content -Path $telemetryFilePath -Raw
$telemetryFileContent = $telemetryFileContent -replace "\d{1,}\.\d{1,}\.\d{1,}", $version.ToString()
Set-Content -Path $telemetryFilePath $telemetryFileContent
}
function Get-CurrentTelemetryVersion([string]$telemetryFilePath) {
$telemetryFileContent = Get-Content -Path $telemetryFilePath -Raw
if($telemetryFileContent -match "(\d{1,}\.\d{1,}\.\d{1,})") {
return [version]::Parse($Matches[1])
} else {
Write-Error "Invalid version number format"
return $null;
}
}
function Update-MinorVersionNumber([version]$currentVersion) {
return [version]::new($currentVersion.Major, $currentVersion.Minor + 1, 0);
}
function Update-MinorVersion() {
$telemetryFilePath = Join-Path -Path $PWD.ToString() -ChildPath "../lib/version_information.rb"
$currentVersion = Get-CurrentTelemetryVersion -telemetryFilePath $telemetryFilePath
$nextVersion = Update-MinorVersionNumber -currentVersion $currentVersion
Update-TelemetryVersion -version $nextVersion -telemetryFilePath $telemetryFilePath
}
Update-MinorVersion