-
-
Notifications
You must be signed in to change notification settings - Fork 682
Expand file tree
/
Copy pathbuild_data_writer.ps1
More file actions
31 lines (26 loc) · 1.06 KB
/
build_data_writer.ps1
File metadata and controls
31 lines (26 loc) · 1.06 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
$OutputPath = $env:OUTPUT
$Lines = @(
"TARGET $env:TARGET",
"CONFIG_MODE $env:CONFIG_MODE",
"STAMPED $env:STAMPED"
)
$VersionFilePath = $env:VERSION_FILE
if (-not [string]::IsNullOrEmpty($VersionFilePath) -and (Test-Path $VersionFilePath)) {
$Lines += Get-Content -Path $VersionFilePath
}
$InfoFilePath = $env:INFO_FILE
if (-not [string]::IsNullOrEmpty($InfoFilePath) -and (Test-Path $InfoFilePath)) {
$Lines += Get-Content -Path $InfoFilePath
}
# Use .NET to write file to avoid PowerShell encoding/locking quirks
# We use UTF8 without BOM for compatibility with how the bash script writes (and
# what consumers expect).
# We join with `n to ensure Unix-style line endings are used even on Windows.
$Utf8NoBom = New-Object System.Text.UTF8Encoding $False
$Content = [string]::Join("`n", $Lines) + "`n"
[System.IO.File]::WriteAllText($OutputPath, $Content, $Utf8NoBom)
$Acl = Get-Acl $OutputPath
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("Everyone", "Read", "Allow")
$Acl.SetAccessRule($AccessRule)
Set-Acl $OutputPath $Acl
exit 0