Skip to content

Commit 7053365

Browse files
Version script runs on windows and linux
1 parent b178785 commit 7053365

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

Scripts/getLatestVersion.ps1

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
Retrieve the latest version of the library
77
.Description
88
Retrieves the latest version specified in the Gradle.Properties file
9-
Uses the retrieved values to update the enviornment variable VERSION_STRING
9+
Uses the retrieved values to update the environment variable VERSION_STRING
1010
.Parameter propertiesPath
11+
The path pointing to the gradle.properties file.
1112
#>
13+
1214
Param(
1315
[string]$propertiesPath
1416
)
@@ -19,13 +21,17 @@ if($propertiesPath -eq "" -or $null -eq $propertiesPath) {
1921
}
2022
$file = get-item $propertiesPath
2123
$findVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2
22-
$findVersions = $findVersions -split "`r`n"
24+
$content = Get-Content $propertiesPath
2325

24-
$versionIndex = $findVersions[0].IndexOf("=")
25-
$majorVersion = $findVersions[0].Substring($versionIndex+2)
26-
$minorVersion = $findVersions[1].Substring($versionIndex+2)
27-
$patchVersion = $findVersions[2].Substring($versionIndex+2)
26+
$lineNumber = $findVersions.LineNumber - 1
27+
$versionIndex = $content[$lineNumber].IndexOf("=")
28+
$versionIndex += 2 # skipping =[space]
29+
$majorVersion = $content[$lineNumber].Substring($versionIndex)
30+
$lineNumber++
31+
$minorVersion = $content[$lineNumber].Substring($versionIndex)
32+
$lineNumber++
33+
$patchVersion = $content[$lineNumber].Substring($versionIndex)
2834
$version = "$majorVersion.$minorVersion.$patchVersion"
2935

30-
#Set Enviornment variable for use to create tag
31-
echo "RELEASE_TAG=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
36+
#Set Task output to create tag
37+
Write-Output "::set-output name=tag::v${version}"

0 commit comments

Comments
 (0)