-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-packagespec.ps1
More file actions
48 lines (39 loc) · 2 KB
/
Copy pathbuild-packagespec.ps1
File metadata and controls
48 lines (39 loc) · 2 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
$Props = convertfrom-stringdata (get-content versions.properties | Select-String -pattern "^#" -NotMatch)
$UpstreamVersion = $Props.UPSTREAM_VERSION
$FileUrl = "https://github.com/rooklift/nibbler/releases/download/v$UpstreamVersion/nibbler-$UpstreamVersion-windows.zip"
"Building Upstream Version: $UpstreamVersion from url $FileUrl"
""
try {
# Erstellt eine HTTP-Anfrage
$request = [System.Net.WebRequest]::Create($FileUrl)
$request.Method = "GET"
# Sendet die Anfrage und erhält den Antwort-Stream
$response = $request.GetResponse()
$stream = $response.GetResponseStream()
# Erstellt ein SHA256-Objekt
$sha256 = [System.Security.Cryptography.SHA256]::Create()
# Berechnet den Hash direkt aus dem Stream
# Die Daten werden in Blöcken gelesen und verarbeitet, nicht auf einmal
$hashBytes = $sha256.ComputeHash($stream)
# Konvertiert das Hash-Byte-Array in einen hexadezimalen String
$UpstreamChecksum = [System.BitConverter]::ToString($hashBytes).Replace("-", "").ToLower()
} finally {
# Schließt den Stream und die Antwort, um Ressourcen freizugeben
if ($stream) { $stream.Close() }
if ($response) { $response.Close() }
}
if (Test-Path -LiteralPath .\target) {
Remove-Item -LiteralPath .\target -Recurse
}
New-Item -ItemType Directory -Force -Path .\target\tools | Out-Null
#
(Get-Content .\src\tools\chocolateyinstall.template.ps1) `
-replace '%%VERSION%%', $UpstreamVersion `
-replace '%%CHECKSUM%%', $UpstreamChecksum |
Out-File -Encoding utf8 ".\target\tools\chocolateyinstall.ps1"
(Get-Content .\src\tools\chocolateyUninstall.template.ps1) `
-replace '%%VERSION%%', $UpstreamVersion `
-replace '%%CHECKSUM%%', $UpstreamChecksum |
Out-File -Encoding utf8 ".\target\tools\chocolateyUninstall.ps1"
Copy-Item .\src\tools\sync-engines.ps1 -Destination ".\target\tools"
(Get-Content .\src\ucichess-nibbler.template.nuspec.xml) -replace '%%VERSION%%', $UpstreamVersion | Out-File -Encoding utf8 ".\target\ucichess-nibbler.nuspec"