-
-
Notifications
You must be signed in to change notification settings - Fork 677
Expand file tree
/
Copy pathbuild_data_writer.ps1
More file actions
29 lines (24 loc) · 964 Bytes
/
build_data_writer.ps1
File metadata and controls
29 lines (24 loc) · 964 Bytes
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
$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).
$Utf8NoBom = New-Object System.Text.UTF8Encoding $False
[System.IO.File]::WriteAllLines($OutputPath, $Lines, $Utf8NoBom)
$Acl = Get-Acl $OutputPath
$AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("Everyone", "Read", "Allow")
$Acl.SetAccessRule($AccessRule)
Set-Acl $OutputPath $Acl
exit 0