Skip to content

Commit 5d03a69

Browse files
Merge pull request #39 from microsoftgraph/rsh/getVersionScript
Rsh/get version script
2 parents 9e55b03 + 2b0f46b commit 5d03a69

File tree

4 files changed

+50
-4
lines changed

4 files changed

+50
-4
lines changed

.azure-pipelines/buildAndPackage.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ trigger:
2323
- gradlew.bat
2424
- readme.md
2525
- settings.gradle
26+
- Scripts/*
2627

2728
pr: none
2829

@@ -82,6 +83,7 @@ steps:
8283
settings.gradle
8384
gradle.properties
8485
**/gradle/wrapper/*
86+
Scripts/getLatestVersion.ps1
8587
TargetFolder: '$(Build.ArtifactStagingDirectory)/'
8688

8789
- task: PublishBuildArtifacts@1

.azure-pipelines/prValidate.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Build and test Java Core to make sure a valid pull request is being made
1+
#Copyright (c) Microsoft Corporation. All rights reserved.
2+
#Licensed under the MIT License.
3+
#Build and test Java Core to make sure a valid pull request is being made
4+
#Validate that the versions dont conflict with those online in case a pull request is made to main or master
5+
26
pr:
37
branches:
48
include:
@@ -18,6 +22,7 @@ pr:
1822
- gradlew.bat
1923
- readme.md
2024
- settings.gradle
25+
- Scripts/*
2126

2227
trigger: none # disable triggers based on commits.
2328

@@ -62,4 +67,4 @@ steps:
6267
title: '$(Build.DefinitionName) failure notification'
6368
text: 'This pipeline has failed. View the build details for further information. This is a blocking failure. '
6469
condition: and(failed(), ne(variables['Build.Reason'], 'Manual'))
65-
enabled: true
70+
enabled: true

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: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,17 @@ $bintrayAPIurl = "https://api.bintray.com/search/packages?name=$packageName"
4343
$jsonResult = $web_client.DownloadString($bintrayAPIurl) | ConvertFrom-Json
4444
$bintrayVersion = [version]$jsonResult.latest_version
4545

46+
#If the api calls return empty then this library cannot be compared to the online versions
47+
#may proceed with the pull request
48+
if(($mavenVersion -eq $null) -and ($bintrayVersion -eq $null))
49+
{
50+
Write-Information "This package does not exist yet in the online repository, therefore there are no versions to compare."
51+
return
52+
}
53+
4654
#Inform host of current Maven and Bintray versions
47-
write-host 'The current version in the Maven central repository is:' $mavenVersion
48-
write-host 'The current version in the Bintray central repository is:' $bintrayVersion
55+
Write-Host 'The current version in the Maven central repository is:' $mavenVersion
56+
Write-Host 'The current version in the Bintray central repository is:' $bintrayVersion
4957

5058
#Warn in case Maven and Bintray versions are not the same.
5159
if($mavenVersion -ne $bintrayVersion){

0 commit comments

Comments
 (0)