Skip to content
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
2 changes: 2 additions & 0 deletions .azure-pipelines/buildAndPackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ trigger:
- gradlew.bat
- readme.md
- settings.gradle
- Scripts/*

pr: none

Expand Down Expand Up @@ -82,6 +83,7 @@ steps:
settings.gradle
gradle.properties
**/gradle/wrapper/*
Scripts/getLatestVersion.ps1
TargetFolder: '$(Build.ArtifactStagingDirectory)/'

- task: PublishBuildArtifacts@1
Expand Down
9 changes: 7 additions & 2 deletions .azure-pipelines/prValidate.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Build and test Java Core to make sure a valid pull request is being made
#Copyright (c) Microsoft Corporation. All rights reserved.
#Licensed under the MIT License.
#Build and test Java Core to make sure a valid pull request is being made
#Validate that the versions dont conflict with those online in case a pull request is made to main or master

pr:
branches:
include:
Expand All @@ -18,6 +22,7 @@ pr:
- gradlew.bat
- readme.md
- settings.gradle
- Scripts/*

trigger: none # disable triggers based on commits.

Expand Down Expand Up @@ -62,4 +67,4 @@ steps:
title: '$(Build.DefinitionName) failure notification'
text: 'This pipeline has failed. View the build details for further information. This is a blocking failure. '
condition: and(failed(), ne(variables['Build.Reason'], 'Manual'))
enabled: true
enabled: true
31 changes: 31 additions & 0 deletions 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

Param(
[parameter(Mandatory = $true)]
[string]$propertiesPath,
)

#Retrieve the current version from the Gradle.Properties file given the specified path
$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"
12 changes: 10 additions & 2 deletions Scripts/validateMavenVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ $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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: should we use -or instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure here either. Initially I was thinking -or also, however I was think this would only lead to another error if there's a version conflict with either the Maven or Jcenter version and we allow it to proceed. With -and we only allow it to proceed if it has not been published to either repository.

{
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
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){
Expand Down