From a49921bb1baeba134f75bccd7127fe8e442b9ee3 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Sat, 15 Oct 2022 15:37:39 +0330 Subject: [PATCH] add github variable helpers (credit: @microsoft) --- scripts/utils.ps1 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index 117f274..ca22479 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -67,6 +67,31 @@ function Digest-Hash($path) { return Invoke-Expression "md5sum $path" } +function Set-GHVariable { + param( + [Parameter(Mandatory = $true)] + [string]$Name, + [Parameter(Mandatory = $true)] + [string]$Value + ) + + Write-Verbose "Setting CI variable $Name to $Value" -Verbose + + if ($env:GITHUB_ENV) { + "$Name=$Value" | Out-File $env:GITHUB_ENV -Append + } +} + +function Get-GHTempPath { + $temp = [System.IO.Path]::GetTempPath() + if ($env:RUNNER_TEMP) { + $temp = $env:RUNNER_TEMP + } + + Write-Verbose "Get CI Temp path: $temp" -Verbose + return $temp +} + function Get-VersionStr() { # Clear existing variable if ($string) { Clear-Variable -name string }