PowerShell/.pipelines/templates/SetVersionVariables.yml

80 lines
2.8 KiB
YAML
Raw Normal View History

parameters:
ReleaseTagVar: v6.2.0
ReleaseTagVarName: ReleaseTagVar
CreateJson: 'no'
UseJson: 'yes'
steps:
- ${{ if eq(parameters['UseJson'],'yes') }}:
- task: DownloadBuildArtifacts@0
inputs:
artifactName: 'drop_prep_SetVars'
itemPattern: '*.json'
downloadPath: '$(System.ArtifactsDirectory)'
displayName: Download Build Info Json
env:
ob_restore_phase: true # This ensures this done in restore phase to workaround signing issue
- powershell: |
$path = "./build.psm1"
if($env:REPOROOT){
Write-Verbose "reporoot already set to ${env:REPOROOT}" -Verbose
exit 0
}
if(Test-Path -Path $path)
{
Write-Verbose "reporoot detect at: ." -Verbose
$repoRoot = '.'
}
else{
$path = "./PowerShell/build.psm1"
if(Test-Path -Path $path)
{
Write-Verbose "reporoot detect at: ./PowerShell" -Verbose
$repoRoot = './PowerShell'
}
}
if($repoRoot) {
$vstsCommandString = "vso[task.setvariable variable=repoRoot]$repoRoot"
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"
} else {
Write-Verbose -Verbose "repo not found"
}
displayName: 'Set repo Root'
env:
ob_restore_phase: true # This ensures this done in restore phase to workaround signing issue
- powershell: |
$createJson = ("${{ parameters.CreateJson }}" -ne "no")
2024-05-24 03:13:03 +08:00
2024-05-24 03:54:14 +08:00
$REPOROOT = $env:REPOROOT
2024-05-24 03:13:03 +08:00
2024-05-24 03:54:14 +08:00
if (-not (Test-Path $REPOROOT/tools/releaseBuild/setReleaseTag.ps1)) {
if ((Test-Path "$REPOROOT/PowerShell/tools/releaseBuild/setReleaseTag.ps1")) {
$REPOROOT = "$REPOROOT/PowerShell"
} else {
throw "Could not find setReleaseTag.ps1 in $REPOROOT/tools/releaseBuild or $REPOROOT/PowerShell/tools/releaseBuild"
2024-05-24 03:13:03 +08:00
}
}
2024-05-24 03:54:14 +08:00
$releaseTag = & "$REPOROOT/tools/releaseBuild/setReleaseTag.ps1" -ReleaseTag ${{ parameters.ReleaseTagVar }} -Variable "${{ parameters.ReleaseTagVarName }}" -CreateJson:$createJson
$version = $releaseTag.Substring(1)
$vstsCommandString = "vso[task.setvariable variable=Version]$version"
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"
$azureVersion = $releaseTag.ToLowerInvariant() -replace '\.', '-'
$vstsCommandString = "vso[task.setvariable variable=AzureVersion]$azureVersion"
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"
displayName: 'Set ${{ parameters.ReleaseTagVarName }} and other version Variables'
env:
ob_restore_phase: true # This ensures this done in restore phase to workaround signing issue
- powershell: |
Get-ChildItem -Path env: | Out-String -width 9999 -Stream | write-Verbose -Verbose
displayName: Capture environment
condition: succeededOrFailed()
env:
ob_restore_phase: true # This ensures this done in restore phase to workaround signing issue