Files
RustDeskAutomaton/scripts/Publish-Artifacts.ps1
Jakub Tucek 472cd9e57c
Some checks failed
rustdesk-auto-build / build-and-publish (push) Has been cancelled
Add scripts for building and managing RustDesk versions
- Implement Build-CustomRustDesk.ps1 to build RustDesk with specified version and configuration.
- Create Get-LastBuiltVersion.ps1 to retrieve the last built version from a state file.
- Add Get-LatestRustDeskVersion.ps1 to fetch the latest version from GitHub releases.
- Develop Invoke-RustDeskPipeline.ps1 to orchestrate the build and deployment process.
- Introduce Publish-Artifacts.ps1 for publishing build artifacts via SMB or SCP.
- Implement Set-LastBuiltVersion.ps1 to update the state file with the last built version.
2026-03-17 14:20:29 +01:00

46 lines
1.3 KiB
PowerShell

function Publish-Artifacts {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$OutputDir,
[Parameter(Mandatory = $true)]
[ValidateSet("smb", "scp")]
[string]$Mode
)
if (-not (Test-Path -LiteralPath $OutputDir)) {
throw "Output directory does not exist: $OutputDir"
}
switch ($Mode) {
"smb" {
if ([string]::IsNullOrWhiteSpace($env:DESTINATION_PATH)) {
throw "DESTINATION_PATH is required for DEPLOY_MODE=smb"
}
New-Item -Path $env:DESTINATION_PATH -ItemType Directory -Force | Out-Null
Copy-Item -Path (Join-Path $OutputDir "*") -Destination $env:DESTINATION_PATH -Recurse -Force
Write-Host "Artifacts copied to SMB/local path: $($env:DESTINATION_PATH)"
}
"scp" {
if ([string]::IsNullOrWhiteSpace($env:SCP_DESTINATION)) {
throw "SCP_DESTINATION is required for DEPLOY_MODE=scp"
}
$scpCommand = Get-Command scp -ErrorAction SilentlyContinue
if (-not $scpCommand) {
throw "scp is not available on this runner. Install OpenSSH client or use DEPLOY_MODE=smb."
}
& scp -r (Join-Path $OutputDir "*") $env:SCP_DESTINATION
if ($LASTEXITCODE -ne 0) {
throw "scp publish failed with exit code $LASTEXITCODE"
}
Write-Host "Artifacts copied using SCP to: $($env:SCP_DESTINATION)"
}
}
}