Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 25c3c59

Browse files
committed
- adds script to auto-increment the version
1 parent ac22f5d commit 25c3c59

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

scripts/incrementMinorVersion.ps1

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
<#
5+
.Synopsis
6+
Increment the minor version string in the gradle.properties if the major,
7+
minor, or patch version hasn't been manually updated.
8+
.Description
9+
Assumptions:
10+
This script assumes it is run from the repo root.
11+
Minor version is typically auto-incremented.
12+
13+
#>
14+
15+
function Update-TelemetryVersion([string]$telemetryFilePath, [version]$version) {
16+
$telemetryFileContent = Get-Content -Path $telemetryFilePath -Raw
17+
$telemetryFileContent = $telemetryFileContent -replace "\d{1,}\.\d{1,}\.\d{1,}", $version.ToString()
18+
Set-Content -Path $telemetryFilePath $telemetryFileContent
19+
}
20+
21+
function Get-CurrentTelemetryVersion([string]$telemetryFilePath) {
22+
$telemetryFileContent = Get-Content -Path $telemetryFilePath -Raw
23+
if($telemetryFileContent -match "(\d{1,}\.\d{1,}\.\d{1,})") {
24+
return [version]::Parse($Matches[1])
25+
} else {
26+
Write-Error "Invalid version number format"
27+
return $null;
28+
}
29+
}
30+
31+
function Update-MinorVersionNumber([version]$currentVersion) {
32+
return [version]::new($currentVersion.Major, $currentVersion.Minor + 1, 0);
33+
}
34+
35+
function Update-MinorVersion() {
36+
$telemetryFilePath = Join-Path -Path $PWD.ToString() -ChildPath "../lib/microsoft_graph/version.rb"
37+
$currentVersion = Get-CurrentTelemetryVersion -telemetryFilePath $telemetryFilePath
38+
$nextVersion = Update-MinorVersionNumber -currentVersion $currentVersion
39+
Update-TelemetryVersion -version $nextVersion -telemetryFilePath $telemetryFilePath
40+
}
41+
Update-MinorVersion

0 commit comments

Comments
 (0)