Skip to content

Commit 99fc981

Browse files
authored
Merge pull request #571 from microsoftgraph/feature/version-increment
feature/version-increment
2 parents 279ee37 + 575bf47 commit 99fc981

File tree

7 files changed

+1556
-159
lines changed

7 files changed

+1556
-159
lines changed

.azure-pipelines/generate-v1.0-models.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ steps:
107107
workingDirectory: '$(Build.SourcesDirectory)' # Set the root for a multi-repo pipeline. /s
108108
enabled: true
109109

110+
- task: PowerShell@2
111+
displayName: 'Increment minor version number'
112+
inputs:
113+
targetType: filePath
114+
filePath: '$(Build.SourcesDirectory)/msgraph-sdk-java/Scripts/incrementMinorVersion.ps1'
115+
workingDirectory: '$(Build.SourcesDirectory)/msgraph-sdk-java/Scripts'
116+
enabled: true
117+
110118
- task: PowerShell@2
111119
displayName: 'Copy generated requests and models into the repo'
112120
inputs:

.github/workflows/create-v1.0-pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
env:
3838
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3939
MESSAGE_TITLE: Generated v1.0 models and request builders using Typewriter
40-
MESSAGE_BODY: "This pull request was automatically created by the GitHub Action, **${{github.workflow}}**. \n\n The commit hash is _${{github.sha}}_. \n\n **Important** Check for unexpected deletions or changes in this PR. \n\n - [ ] update version in gradle.properties and Constants.java. \n\n - [ ] update version in readme.md\n\n- [ ] create tag and release\n\n cc: @darrelmiller"
40+
MESSAGE_BODY: "This pull request was automatically created by the GitHub Action, **${{github.workflow}}**. \n\n The commit hash is _${{github.sha}}_. \n\n **Important** Check for unexpected deletions or changes in this PR. \n\n cc: @darrelmiller"
4141
REVIEWERS: peombwa,ddyett,zengin,nikithauc,baywet
4242
ASSIGNEDTO: baywet
4343
LABELS: generated

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repositories {
1919
2020
dependencies {
2121
// Include the sdk as a dependency
22-
implementation 'com.microsoft.graph:microsoft-graph:2.4.+'
22+
implementation 'com.microsoft.graph:microsoft-graph:2.4.0'
2323
}
2424
```
2525

Scripts/getLatestVersion.ps1

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

Scripts/incrementMinorVersion.ps1

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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, [string]$version) {
17+
$readmeFileContent = Get-Content -Path $readmeFilePath -Raw
18+
$readmeFileContent = $readmeFileContent -replace "\d{1,}\.\d{1,}\.\d{1,}", $version
19+
Set-Content -Path $readmeFilePath $readmeFileContent
20+
}
21+
22+
function Update-TelemetryVersion([string]$telemetryFilePath, [string]$version) {
23+
$telemetryFileContent = Get-Content -Path $telemetryFilePath -Raw
24+
$telemetryFileContent = $telemetryFileContent -replace "\d{1,}\.\d{1,}\.\d{1,}", $version
25+
Set-Content -Path $telemetryFilePath $telemetryFileContent
26+
}
27+
28+
function Update-PackageVersion([string]$propertiesFilePath, [string]$version) {
29+
$propertiesFileContent = Get-Content -Path $propertiesFilePath -Raw
30+
if($version -match "(\d{1,})\.(\d{1,})\.(\d{1,})") {
31+
$patch = $Matches[3]
32+
$minor = $Matches[2]
33+
$major = $Matches[1]
34+
$propertiesFileContent = $propertiesFileContent -replace "mavenMajorVersion\s+=\s+\d{1,}", "mavenMajorVersion = $major"
35+
$propertiesFileContent = $propertiesFileContent -replace "mavenMinorVersion\s+=\s+\d{1,}", "mavenMinorVersion = $minor"
36+
$propertiesFileContent = $propertiesFileContent -replace "mavenPatchVersion\s+=\s+\d{1,}", "mavenPatchVersion = $patch"
37+
Set-Content -Path $propertiesFilePath $propertiesFileContent
38+
} else {
39+
Write-Error "Invalid version number format $version"
40+
}
41+
}
42+
function Get-CurrentTelemetryVersion([string]$telemetryFilePath) {
43+
$telemetryFileContent = Get-Content -Path $telemetryFilePath -Raw
44+
if($telemetryFileContent -match "(\d{1,}\.\d{1,}\.\d{1,})") {
45+
return $Matches[1]
46+
} else {
47+
Write-Error "Invalid version number format"
48+
return ""
49+
}
50+
}
51+
52+
function Update-MinorVersionNumber([string]$currentVersion) {
53+
if($currentVersion -match "(\d{1,})\.(\d{1,})\.(\d{1,})") {
54+
[int]$minor = [convert]::ToInt32($Matches[2])
55+
$minor++;
56+
$major = $Matches[1]
57+
return "$major.$minor.0"
58+
} else {
59+
Write-Error "Invalid version number format $currentVersion"
60+
return ""
61+
}
62+
}
63+
64+
function Update-MinorVersion() {
65+
$readmeFilePath = Join-Path -Path $PWD.ToString() -ChildPath "../readme.md"
66+
$propertiesFilePath = Join-Path -Path $PWD.ToString() -ChildPath "../gradle.properties"
67+
$telemetryFilePath = Join-Path -Path $PWD.ToString() -ChildPath "../src/main/java/com/microsoft/graph/core/Constants.java"
68+
$currentVersion = Get-CurrentTelemetryVersion -telemetryFilePath $telemetryFilePath
69+
$nextVersion = Update-MinorVersionNumber -currentVersion $currentVersion
70+
Update-ReadmeVersion -version $nextVersion -readmeFilePath $readmeFilePath
71+
Update-TelemetryVersion -version $nextVersion -telemetryFilePath $telemetryFilePath
72+
Update-PackageVersion -version $nextVersion -propertiesFilePath $propertiesFilePath
73+
}
74+
Update-MinorVersion

Scripts/validateMavenVersion.ps1

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

0 commit comments

Comments
 (0)