generated from MrSphay/codex-agent-repository-kit
77 lines
3.1 KiB
PowerShell
77 lines
3.1 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[string]$Version = "0.1.0",
|
|
[string]$OutputDirectory = ".\dist",
|
|
[string]$SigningThumbprint,
|
|
[switch]$NoTimestamp,
|
|
[switch]$AllowUntrustedRoot
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
function Resolve-FullPath {
|
|
param([Parameter(Mandatory)][string]$Path)
|
|
|
|
$executionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path)
|
|
}
|
|
|
|
$root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
|
$output = Resolve-FullPath $OutputDirectory
|
|
$packageRoot = Join-Path $output "MrTrust-$Version"
|
|
$zipPath = Join-Path $output "MrTrust-$Version.zip"
|
|
$exePath = Join-Path $output "MrTrust.exe"
|
|
$iconPath = Join-Path $root "assets\MrTrust.ico"
|
|
|
|
if (Test-Path -LiteralPath $packageRoot) {
|
|
Remove-Item -LiteralPath $packageRoot -Recurse -Force
|
|
}
|
|
|
|
New-Item -ItemType Directory -Force -Path $packageRoot | Out-Null
|
|
New-Item -ItemType Directory -Force -Path (Join-Path $packageRoot "scripts") | Out-Null
|
|
New-Item -ItemType Directory -Force -Path (Join-Path $packageRoot "assets\certificates") | Out-Null
|
|
New-Item -ItemType Directory -Force -Path (Join-Path $packageRoot "docs") | Out-Null
|
|
|
|
if (-not (Test-Path -LiteralPath $iconPath)) {
|
|
& (Join-Path $root "scripts\New-MrTrustIcon.ps1") -OutputPath $iconPath
|
|
}
|
|
|
|
& (Join-Path $root "scripts\Build-MrTrustExe.ps1") -OutputPath $exePath
|
|
|
|
if ($SigningThumbprint) {
|
|
$signArguments = @{
|
|
Path = $exePath
|
|
CertificateThumbprint = $SigningThumbprint
|
|
}
|
|
|
|
if ($NoTimestamp) {
|
|
$signArguments.NoTimestamp = $true
|
|
}
|
|
|
|
if ($AllowUntrustedRoot) {
|
|
$signArguments.AllowUntrustedRoot = $true
|
|
}
|
|
|
|
& (Join-Path $root "scripts\Sign-MrTrustProject.ps1") @signArguments
|
|
}
|
|
|
|
Copy-Item -LiteralPath $exePath -Destination $packageRoot
|
|
Copy-Item -LiteralPath (Join-Path $root "MrTrust.ps1") -Destination $packageRoot
|
|
Copy-Item -LiteralPath (Join-Path $root "README.md") -Destination $packageRoot
|
|
Copy-Item -LiteralPath $iconPath -Destination (Join-Path $packageRoot "assets")
|
|
Copy-Item -LiteralPath (Join-Path $root "scripts\Install-MrTrust.ps1") -Destination (Join-Path $packageRoot "scripts")
|
|
Copy-Item -LiteralPath (Join-Path $root "scripts\Uninstall-MrTrust.ps1") -Destination (Join-Path $packageRoot "scripts")
|
|
Copy-Item -LiteralPath (Join-Path $root "scripts\Start-MrTrustGui.ps1") -Destination (Join-Path $packageRoot "scripts")
|
|
Copy-Item -LiteralPath (Join-Path $root "assets\certificates\MrSphay-LocalTrust-Root.cer") -Destination (Join-Path $packageRoot "assets\certificates")
|
|
Copy-Item -LiteralPath (Join-Path $root "assets\certificates\MrSphay-CodeSigning.cer") -Destination (Join-Path $packageRoot "assets\certificates")
|
|
Copy-Item -LiteralPath (Join-Path $root "assets\certificates\thumbprints.txt") -Destination (Join-Path $packageRoot "assets\certificates")
|
|
Copy-Item -LiteralPath (Join-Path $root "docs\security-model.md") -Destination (Join-Path $packageRoot "docs")
|
|
|
|
if (Test-Path -LiteralPath $zipPath) {
|
|
Remove-Item -LiteralPath $zipPath -Force
|
|
}
|
|
|
|
Compress-Archive -Path (Join-Path $packageRoot "*") -DestinationPath $zipPath -Force
|
|
|
|
Write-Host "Created release package:"
|
|
Write-Host " $zipPath"
|