Skip to content

Commit 070838f

Browse files
committed
Update script
1 parent 106ce1f commit 070838f

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

‎Scripts/validateMavenVersion.ps1‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@
88
.Description
99
#>
1010

11+
.Parameter packageName
12+
.Parameter propertiesPath
1113

14+
Param(
15+
[parameter(Mandatory = $true)]
16+
[string]$packageName,
1217

13-
$fullFileName = $PWD.toString + "\gradle.properties"
14-
$file = get-item $fullFileName
18+
[parameter(Mandatory = $true)]
19+
[string]$propertiesPath
20+
)
21+
22+
$file = get-item $propertiesPath
1523
$findVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2
1624
$localVersions = $findVersions -split "`r`n"
1725

@@ -24,45 +32,40 @@ $localMinorVersion = [int]$localMinorVersion.Substring($localMinorVersion.Length
2432
$localPatchVersion = $localVersions[2]
2533
$localPatchVersion = [int]$localPatchVersion.Substring($localPatchVersion.Length-1)
2634

27-
2835
$web_client = New-Object System.Net.WebClient
2936

30-
$mavenAPIurl = 'https://search.maven.org/solrsearch/select?q=microsoft-graph-core&rows=20&wt=json'
37+
$mavenAPIurl = 'https://search.maven.org/solrsearch/select?q=$packageName&rows=20&wt=json'
3138
$jsonResult = $web_client.DownloadString($mavenAPIurl) | ConvertFrom-Json
3239
$mavenVersions = $jsonResult.response.docs.v
3340
$mavenSplit = $mavenVersions.split(".")
3441
$mavenMajorVersion = [int]$mavenSplit[0]
3542
$mavenMinorVersion = [int]$mavenSplit[1]
3643
$mavenPatchVersion = [int]$mavenSplit[2]
3744

38-
$bintrayAPIurl = 'https://api.bintray.com/search/packages?name=microsoft-graph-core'
45+
$bintrayAPIurl = 'https://api.bintray.com/search/packages?name=$packageName'
3946
$jsonResult = $web_client.DownloadString($bintrayAPIurl) | ConvertFrom-Json
4047
$bintrayVersions = $jsonResult.latest_version
4148
$bintraySplit = $bintrayVersions.split(".")
4249
$bintrayMajorVersion = [int]$bintraySplit[0]
4350
$bintrayMinorVersion = [int]$bintraySplit[1]
4451
$bintrayPatchVersion = [int]$bintraySplit[2]
4552

46-
4753
write-host 'The current version in the Maven central repository is:' $mavenVersions
4854
write-host 'The current version in the Bintray central repository is:' $bintrayVersions
4955

5056
if(($bintrayMinorVersion -ne $mavenMinorVersion) -OR
5157
($bintrayMajorversion -ne $mavenMajorVersion) -OR
52-
($bintraypatchversion -ne $mavenpatchversion))
53-
{
58+
($bintraypatchversion -ne $mavenpatchversion)){
5459
Write-Warning "The current Maven and Bintray versions are not the same"
5560
}
5661

5762
if(($localMajorVersion -gt $bintrayMajorVersion) -OR
5863
($localMinorVersion -gt $bintrayMinorVersion) -OR
59-
($localPatchVersion -gt $bintrayPatchVersion))
60-
{
61-
write-host "The current pull request is of a greater version"
64+
($localPatchVersion -gt $bintrayPatchVersion)){
65+
Write-Host "The current pull request is of a greater version"
6266
}
63-
else
64-
{
65-
write-error "The local version has not been updated or is of an earlier version than that on the remote repository"
67+
else{
68+
Write-Error "The local version has not been updated or is of an earlier version than that on the remote repository"
6669
}
6770

6871

0 commit comments

Comments
 (0)