Skip to content

Commit 43b1029

Browse files
committed
- fixes #434 : adds github release scripts for automated release creation
1 parent 4f5f179 commit 43b1029

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

Scripts/getLatestVersion.ps1

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
<#
5+
.Synopsis
6+
Retrieve the latest version of the library
7+
.Description
8+
Retrieves the latest version specified in the Gradle.Properties file
9+
Uses the retrieved values to update the enviornment variable VERSION_STRING
10+
#>
11+
12+
.Parameter propertiesPath
13+
14+
Param(
15+
[parameter(Mandatory = $true)]
16+
[string]$propertiesPath
17+
)
18+
19+
#Retrieve the current version from the Gradle.Properties file given the specified path
20+
$file = get-item $propertiesPath
21+
$findVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2
22+
$findVersions = $findVersions -split "`r`n"
23+
24+
$majorVersion = $findVersions[0].Substring($findVersions[0].Length-1)
25+
$minorVersion = $findVersions[1].Substring($findVersions[1].Length-1)
26+
$patchVersion = $findVersions[2].Substring($findVersions[2].Length-1)
27+
$version = "$majorVersion.$minorVersion.$patchVersion"
28+
29+
#Update the VERSION_STRING env variable and inform the user
30+
Write-Host "##vso[task.setVariable variable=VERSION_STRING]$($version)";
31+
Write-Host "Updated the VERSION_STRING enviornment variable with the current Gradle.Properties, $version"

Scripts/validateMavenVersion.ps1

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
Retrieves the local, Maven, and Bintray versions of the Java-Core build.
10+
Checks that the Maven and Bintray versions are aligned, trigger warning if not.
11+
Checks that the current local version is greater than those currently deployed.
12+
.Parameter propertiesPath
13+
#>
14+
15+
16+
Param(
17+
[string]$propertiesPath
18+
)
19+
20+
#Find the local version from the Gradle.Properties file
21+
if($propertiesPath -eq "" -or $null -eq $propertiesPath) {
22+
$propertiesPath = Join-Path -Path $PSScriptRoot -ChildPath "../gradle.properties"
23+
}
24+
$file = get-item $propertiesPath
25+
$findLocalVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2
26+
$findLocalVersions = $findLocalVersions -split "`r`n"
27+
$packageName = ($file | Select-String -Pattern "mavenArtifactId").Line.Split("=")[1].Trim()
28+
29+
$localMajor = $findLocalVersions[0].Substring($findLocalVersions[0].Length-1)
30+
$localMinor = $findLocalVersions[1].Substring($findLocalVersions[1].Length-1)
31+
$localPatch = $findLocalVersions[2].Substring($findLocalVersions[2].Length-1)
32+
$localVersion = [version]"$localMajor.$localMinor.$localPatch"
33+
34+
#Set Web Client and retrieve Maven and Bintray versions from their respective repos.
35+
$web_client = New-Object System.Net.WebClient
36+
37+
$mavenAPIurl = "https://search.maven.org/solrsearch/select?q=$packageName&rows=20&wt=json"
38+
$jsonResult = $web_client.DownloadString($mavenAPIurl) | ConvertFrom-Json
39+
$mavenVersion = [version]$jsonResult.response.docs.latestVersion
40+
41+
$bintrayAPIurl = "https://api.bintray.com/search/packages?name=$packageName"
42+
$jsonResult = $web_client.DownloadString($bintrayAPIurl) | ConvertFrom-Json
43+
$bintrayVersion = [version]$jsonResult.latest_version
44+
45+
#If the api calls return empty then this library cannot be compared to the online versions
46+
#may proceed with the pull request
47+
if(($mavenVersion -eq $null) -and ($bintrayVersion -eq $null))
48+
{
49+
Write-Information "This package does not exist yet in the online repository, therefore there are no versions to compare."
50+
return
51+
}
52+
53+
#Inform host of current Maven and Bintray versions
54+
Write-Host 'The current version in the Maven central repository is:' $mavenVersion
55+
Write-Host 'The current version in the Bintray central repository is:' $bintrayVersion
56+
57+
#Warn in case Maven and Bintray versions are not the same.
58+
if($mavenVersion -ne $bintrayVersion){
59+
Write-Warning "The current Maven and Bintray versions are not the same"
60+
}
61+
#Success if Local version has been updated, Error otherwise.
62+
if($localVersion -gt $bintrayVersion -and $localVersion -gt $mavenVersion){
63+
Write-Host "The current pull request is of a greater version"
64+
}
65+
else{
66+
Write-Error "The current local version is not updated. Please update the local version in the Gradle.Properties file."
67+
}

0 commit comments

Comments
 (0)