forked from microsoftgraph/msgraph-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetLatestVersion.ps1
More file actions
37 lines (32 loc) · 1.29 KB
/
getLatestVersion.ps1
File metadata and controls
37 lines (32 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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 environment variable VERSION_STRING
.Parameter propertiesPath
The path pointing to the gradle.properties file.
#>
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
$content = Get-Content $propertiesPath
$lineNumber = $findVersions.LineNumber - 1
$versionIndex = $content[$lineNumber].IndexOf("=")
$versionIndex += 2 # skipping =[space]
$majorVersion = $content[$lineNumber].Substring($versionIndex)
$lineNumber++
$minorVersion = $content[$lineNumber].Substring($versionIndex)
$lineNumber++
$patchVersion = $content[$lineNumber].Substring($versionIndex)
$version = "$majorVersion.$minorVersion.$patchVersion"
#Set Task output to create tag
Write-Output "::set-output name=tag::v${version}"