Repository navigation
Expand file tree
/
Copy pathbuild.ps1
More file actions
55 lines (45 loc) · 2.09 KB
/
Copy pathbuild.ps1
File metadata and controls
55 lines (45 loc) · 2.09 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
48
49
50
51
52
53
54
55
param(
[string]$Version = "0.1.28",
[switch]$SkipSmokeTests
)
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $root
if (-not $SkipSmokeTests) {
Write-Host "Running smoke tests..." -ForegroundColor Cyan
dotnet run --project tools\SmokeTests\SmokeTests.csproj -c Release
if ($LASTEXITCODE -ne 0) { throw "Smoke tests failed." }
}
$dist = Join-Path $root "dist\MistShell-$Version-win-x64"
if (Test-Path $dist) { Remove-Item $dist -Recurse -Force }
Write-Host "Publishing $Version..." -ForegroundColor Cyan
dotnet publish src\MistShell\MistShell.csproj `
-c Release -r win-x64 --self-contained true `
-p:PublishSingleFile=false -p:DebugType=None -p:DebugSymbols=false `
-o $dist
if ($LASTEXITCODE -ne 0) { throw "Publish failed." }
$data = Join-Path $dist "data"
if (Test-Path $data) { Remove-Item $data -Recurse -Force }
Copy-Item README.md, LICENSE, THIRD-PARTY-NOTICES.md, CHANGELOG.md $dist -Force
if (Test-Path docs) { Copy-Item docs $dist -Recurse -Force }
if (Test-Path (Join-Path $dist "data")) { throw "Refusing to package a data directory." }
$sensitiveFiles = @()
foreach ($file in Get-ChildItem $dist -Recurse -File) {
if ($file.Name -in @("connections.json", "settings.json", "known_hosts", "authorized_keys") -or
$file.Name -like "id_rsa*" -or
$file.Extension -in @(".key", ".pem", ".ppk", ".pub", ".p12", ".pfx", ".crt", ".cer", ".log")) {
$sensitiveFiles += $file.FullName
}
}
if ($sensitiveFiles.Count -gt 0) {
throw "Refusing to package sensitive files:`n$($sensitiveFiles -join "`n")"
}
$zip = Join-Path $root "dist\MistShell-$Version-win-x64.zip"
if (Test-Path $zip) { Remove-Item $zip -Force }
Compress-Archive -Path (Join-Path $dist "*") -DestinationPath $zip -CompressionLevel Optimal
$packageDir = "G:\tools"
if (-not (Test-Path $packageDir)) { New-Item -ItemType Directory -Path $packageDir | Out-Null }
$packageZip = Join-Path $packageDir "mistShell.zip"
Copy-Item $zip $packageZip -Force
Write-Host "Done: $zip" -ForegroundColor Green
Write-Host "Copied: $packageZip" -ForegroundColor Green