Skip to content

Commit bf16ff9

Browse files
committed
- fixes the get version script to be able to run on linux as well
- uses task ouput instead of environment variable Signed-off-by: Vincent Biret <[email protected]>
1 parent cf76178 commit bf16ff9

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

.github/workflows/build-and-publish.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,17 @@ jobs:
9898
9999
create_Tag:
100100
needs: maven_Release
101-
runs-on: windows-latest
101+
runs-on: ubuntu-latest
102102
env:
103103
RELEASE_TAG: ""
104104
steps:
105105
- uses: actions/checkout@v2
106106
- name: Get Version
107+
id: GetVersion
107108
run: .\scripts\getLatestVersion.ps1
108109
shell: pwsh
109110
- name: Create tag
110111
uses: rickstaa/[email protected]
111112
with:
112-
tag: "v$RELEASE_TAG"
113+
tag: ${{ steps.GetVersion.outputs.tag }}
113114

scripts/getLatestVersion.ps1

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ if($propertiesPath -eq "" -or $null -eq $propertiesPath) {
2121
}
2222
$file = get-item $propertiesPath
2323
$findVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2
24-
$findVersions = $findVersions -split "`r`n"
24+
$content = Get-Content $propertiesPath
2525

26-
$versionIndex = $findVersions[0].IndexOf("=")
27-
$majorVersion = $findVersions[0].Substring($versionIndex+2)
28-
$minorVersion = $findVersions[1].Substring($versionIndex+2)
29-
$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)
3034
$version = "$majorVersion.$minorVersion.$patchVersion"
3135

32-
#Set Enviornment variable for use to create tag
33-
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)