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+ Targets Gradle.properties
11+ This script assumes it is run from the repo root.
12+ Minor version is typically auto-incremented.
13+
14+ #>
15+
16+ function Update-ReadmeVersion ([string ]$readmeFilePath , [version ]$version ) {
17+ $readmeFileContent = Get-Content - Path $readmeFilePath - Raw
18+ $readmeFileContent = $readmeFileContent -replace " \d{1,}\.\d{1,}\.\d{1,}" , $version.ToString ()
19+ Set-Content - Path $readmeFilePath $readmeFileContent
20+ }
21+
22+ function Update-TelemetryVersion ([string ]$telemetryFilePath , [version ]$version ) {
23+ $telemetryFileContent = Get-Content - Path $telemetryFilePath - Raw
24+ $telemetryFileContent = $telemetryFileContent -replace " \d{1,}\.\d{1,}\.\d{1,}" , $version.ToString ()
25+ Set-Content - Path $telemetryFilePath $telemetryFileContent
26+ }
27+
28+ function Update-PackageVersion ([string ]$propertiesFilePath , [version ]$version ) {
29+ $propertiesFileContent = Get-Content - Path $propertiesFilePath - Raw
30+ $propertiesFileContent = $propertiesFileContent -replace " mavenMajorVersion\s+=\s+\d{1,}" , " mavenMajorVersion = $ ( $version.Major ) "
31+ $propertiesFileContent = $propertiesFileContent -replace " mavenMinorVersion\s+=\s+\d{1,}" , " mavenMinorVersion = $ ( $version.Minor ) "
32+ $propertiesFileContent = $propertiesFileContent -replace " mavenPatchVersion\s+=\s+\d{1,}" , " mavenPatchVersion = $ ( $version.Build ) "
33+ Set-Content - Path $propertiesFilePath $propertiesFileContent
34+ }
35+ function Get-CurrentTelemetryVersion ([string ]$telemetryFilePath ) {
36+ $telemetryFileContent = Get-Content - Path $telemetryFilePath - Raw
37+ if ($telemetryFileContent -match " (\d{1,}\.\d{1,}\.\d{1,})" ) {
38+ return [version ]::Parse($Matches [1 ])
39+ } else {
40+ Write-Error " Invalid version number format"
41+ return $null ;
42+ }
43+ }
44+
45+ function Update-MinorVersionNumber ([version ]$currentVersion ) {
46+ return [version ]::new($currentVersion.Major , $currentVersion.Minor + 1 , 0 );
47+ }
48+
49+ function Update-MinorVersion () {
50+ $readmeFilePath = Join-Path - Path $PWD.ToString () - ChildPath " ../readme.md"
51+ $propertiesFilePath = Join-Path - Path $PWD.ToString () - ChildPath " ../gradle.properties"
52+ $telemetryFilePath = Join-Path - Path $PWD.ToString () - ChildPath " ../src/main/java/com/microsoft/graph/httpcore/TelemetryHandler.java"
53+ $currentVersion = Get-CurrentTelemetryVersion - telemetryFilePath $telemetryFilePath
54+ $nextVersion = Update-MinorVersionNumber - currentVersion $currentVersion
55+ Update-ReadmeVersion - version $nextVersion - readmeFilePath $readmeFilePath
56+ Update-TelemetryVersion - version $nextVersion - telemetryFilePath $telemetryFilePath
57+ Update-PackageVersion - version $nextVersion - propertiesFilePath $propertiesFilePath
58+ }
59+ Update-MinorVersion
0 commit comments