Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions 31 Scripts/getLatestVersion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

<#
.Synopsis
Retrieve the latest version of the library
.Description
Retrieves the latest version specified in the Gradle.Properties file
Uses the retrieved values to update the enviornment variable VERSION_STRING
.Parameter propertiesPath
baywet marked this conversation as resolved.
Show resolved Hide resolved
#>
Param(
[string]$propertiesPath
)

#Retrieve the current version from the Gradle.Properties file given the specified path
if($propertiesPath -eq "" -or $null -eq $propertiesPath) {
$propertiesPath = Join-Path -Path $PSScriptRoot -ChildPath "../gradle.properties"
}
$file = get-item $propertiesPath
$findVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2
$findVersions = $findVersions -split "`r`n"

$majorVersion = $findVersions[0].Substring($findVersions[0].Length-1)
$minorVersion = $findVersions[1].Substring($findVersions[1].Length-1)
$patchVersion = $findVersions[2].Substring($findVersions[2].Length-1)
$version = "$majorVersion.$minorVersion.$patchVersion"

#Update the VERSION_STRING env variable and inform the user
Write-Host "##vso[task.setVariable variable=VERSION_STRING]$($version)";
Write-Host "Updated the VERSION_STRING enviornment variable with the current Gradle.Properties, $version"
67 changes: 67 additions & 0 deletions 67 Scripts/validateMavenVersion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

<#
.Synopsis
Ensure the maven version is updated in the case that the pull request is
to the main/master branch of the repo.
.Description
Retrieves the local, Maven, and Bintray versions of the Java-Core build.
Checks that the Maven and Bintray versions are aligned, trigger warning if not.
Checks that the current local version is greater than those currently deployed.
.Parameter propertiesPath
#>


Param(
[string]$propertiesPath
)

#Find the local version from the Gradle.Properties file
if($propertiesPath -eq "" -or $null -eq $propertiesPath) {
$propertiesPath = Join-Path -Path $PSScriptRoot -ChildPath "../gradle.properties"
}
$file = get-item $propertiesPath
$findLocalVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2
$findLocalVersions = $findLocalVersions -split "`r`n"
$packageName = ($file | Select-String -Pattern "mavenArtifactId").Line.Split("=")[1].Trim()

$localMajor = $findLocalVersions[0].Substring($findLocalVersions[0].Length-1)
$localMinor = $findLocalVersions[1].Substring($findLocalVersions[1].Length-1)
$localPatch = $findLocalVersions[2].Substring($findLocalVersions[2].Length-1)
$localVersion = [version]"$localMajor.$localMinor.$localPatch"

#Set Web Client and retrieve Maven and Bintray versions from their respective repos.
$web_client = New-Object System.Net.WebClient

$mavenAPIurl = "https://search.maven.org/solrsearch/select?q=$packageName&rows=20&wt=json"
$jsonResult = $web_client.DownloadString($mavenAPIurl) | ConvertFrom-Json
$mavenVersion = [version]$jsonResult.response.docs.latestVersion

$bintrayAPIurl = "https://api.bintray.com/search/packages?name=$packageName"
$jsonResult = $web_client.DownloadString($bintrayAPIurl) | ConvertFrom-Json
$bintrayVersion = [version]$jsonResult.latest_version

#If the api calls return empty then this library cannot be compared to the online versions
#may proceed with the pull request
if(($mavenVersion -eq $null) -and ($bintrayVersion -eq $null))
{
Write-Information "This package does not exist yet in the online repository, therefore there are no versions to compare."
return
}

#Inform host of current Maven and Bintray versions
Write-Host 'The current version in the Maven central repository is:' $mavenVersion
Write-Host 'The current version in the Bintray central repository is:' $bintrayVersion

#Warn in case Maven and Bintray versions are not the same.
if($mavenVersion -ne $bintrayVersion){
Write-Warning "The current Maven and Bintray versions are not the same"
}
#Success if Local version has been updated, Error otherwise.
if($localVersion -gt $bintrayVersion -and $localVersion -gt $mavenVersion){
Write-Host "The current pull request is of a greater version"
}
else{
Write-Error "The current local version is not updated. Please update the local version in the Gradle.Properties file."
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.