Skip to content

Commit 1176583

Browse files
committed
updated script file to check if the local maven version is greater than those on the repo
1 parent 0db442b commit 1176583

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

Scripts/validateMavenVersion.ps1

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
<#
5+
.Synopsis
6+
Ensure the maven version is updated in the case that the pull request is
7+
to the main/master branch of the repo.
8+
.Description
9+
#>
10+
11+
12+
13+
$fullFileName = $PWD.toString + "\gradle.properties"
14+
$file = get-item $fullFileName
15+
$findVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2
16+
$localVersions = $findVersions -split "`r`n"
17+
18+
$localMajorVersion = $localVersions[0]
19+
$localMajorVersion = [int]$localMajorVersion.Substring($localMajorVersion.Length-1)
20+
21+
$localMinorVersion = $localVersions[1]
22+
$localMinorVersion = [int]$localMinorVersion.Substring($localMinorVersion.Length-1)
23+
24+
$localPatchVersion = $localVersions[2]
25+
$localPatchVersion = [int]$localPatchVersion.Substring($localPatchVersion.Length-1)
26+
27+
28+
$web_client = New-Object System.Net.WebClient
29+
30+
$mavenAPIurl = 'https://search.maven.org/solrsearch/select?q=g:"com.microsoft.graph"+AND+a:"microsoft-graph-core"&core=gav&rows=20&wt=json'
31+
$jsonResult = $web_client.DownloadString($mavenAPIurl) | ConvertFrom-Json
32+
$mavenVersions = $jsonResult.response.docs.v.split(".")
33+
$mavenMajorVersion = [int]$mavenVersions[0]
34+
$mavenMinorVersion = [int]$mavenVersions[1]
35+
$mavenPatchVersion = [int]$mavenVersions[2]
36+
37+
$bintrayAPIurl = 'https://api.bintray.com/search/packages?name=microsoft-graph-core'
38+
$jsonResult = $web_client.DownloadString($bintrayAPIurl) | ConvertFrom-Json
39+
$bintrayVersions = $jsonResult.latest_version.split(".")
40+
$bintrayMajorVersion = [int]$bintrayVersions[0]
41+
$bintrayMinorVersion = [int]$bintrayVersions[1]
42+
$bintrayPatchVersion = [int]$bintrayVersions[2]
43+
44+
if(($bintrayMinorVersion -ne $mavenMinorVersion) -OR
45+
($bintrayMajorversion -ne $mavenMajorVersion) -OR
46+
($bintraypatchversion -ne $mavenpatchversion))
47+
{
48+
"The current Maven and Bintray versions are not the same"
49+
}
50+
else {
51+
if(($localMajorVersion -gt $bintrayMajorVersion) -OR
52+
($localMinorVersion -gt $bintrayMinorVersion) -OR
53+
($localPatchVersion -gt $bintrayPatchVersion))
54+
{
55+
"The current pull request is of a greater version"
56+
}
57+
}
58+
59+
60+
61+
62+
63+
64+
65+
66+

0 commit comments

Comments
 (0)