Skip to content

Commit 9a864ed

Browse files
authored
Merge pull request #89 from microsoftgraph/feature/version-increment
feature/version-increment
2 parents 862acfd + 4172c36 commit 9a864ed

File tree

4 files changed

+60
-75
lines changed

4 files changed

+60
-75
lines changed

.azure-pipelines/buildAndPackage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ steps:
8585
settings.gradle
8686
gradle.properties
8787
**/gradle/wrapper/*
88-
Scripts/getLatestVersion.ps1
88+
Scripts/**
8989
TargetFolder: '$(Build.ArtifactStagingDirectory)/'
9090

9191
- task: PublishBuildArtifacts@1

.azure-pipelines/prValidate.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,6 @@ steps:
4343
inputs:
4444
debugMode: false
4545

46-
- task: PowerShell@2
47-
condition: and(failed(), eq(variables['Build.SourceBranchName'], 'dev'))
48-
inputs:
49-
filePath: '$(System.DefaultWorkingDirectory)\Scripts\validateMavenVersion.ps1'
50-
pwsh: true
51-
arguments: '-packageName "$(PACKAGE_NAME)" -propertiesPath "$(PROPERTIES_PATH)"'
52-
5346
- task: Gradle@2
5447
inputs:
5548
gradleWrapperFile: 'gradlew'

Scripts/incrementMinorVersion.ps1

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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

Scripts/validateMavenVersion.ps1

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)