feat: add cross-platform release pipeline [CI SKIP]
This commit is contained in:
1 parent
26620707a0
commit
deceeb19f3
27 files changed
+1036
-18
No files matched your search
@@ -0,0 +1,75 @@
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateSet(
|
||||
'linux-x64', 'linux-arm64',
|
||||
'linux-musl-x64', 'linux-musl-arm64',
|
||||
'osx-x64', 'osx-arm64', 'win-x64', 'win-arm64'
|
||||
)]
|
||||
[string]$RuntimeIdentifier,
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateSet('agent', 'probe', 'fleet-enroll')]
|
||||
[string]$Component
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
if (-not $env:CI_COMMIT_TAG -or $env:CI_COMMIT_TAG -notmatch '^v(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$') {
|
||||
throw 'Release must run from a vMAJOR.MINOR.PATCH tag.'
|
||||
}
|
||||
$version = $Matches[1]
|
||||
$root = Split-Path -Parent $PSScriptRoot
|
||||
$backend = Join-Path $root 'backend'
|
||||
$projectVersion = [regex]::Match((Get-Content (Join-Path $backend 'Directory.Build.props') -Raw), '<Version>([^<]+)</Version>').Groups[1].Value
|
||||
if ($version -ne $projectVersion) {
|
||||
throw "Tag version $version does not match project version $projectVersion."
|
||||
}
|
||||
|
||||
if ($RuntimeIdentifier -in @('win-x64', 'win-arm64')) {
|
||||
$vcArchitecture = if ($RuntimeIdentifier -eq 'win-x64') { 'x64' } else { 'arm64' }
|
||||
$vsWhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
|
||||
$vsPath = & $vsWhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath
|
||||
if (-not $vsPath) {
|
||||
throw 'Visual Studio C++ Build Tools were not found.'
|
||||
}
|
||||
$devCmd = Join-Path $vsPath 'Common7\Tools\VsDevCmd.bat'
|
||||
$environmentLines = & cmd.exe /d /s /c "call `"$devCmd`" -no_logo -arch=$vcArchitecture -host_arch=x64 && set"
|
||||
foreach ($line in $environmentLines) {
|
||||
$separator = $line.IndexOf('=')
|
||||
if ($separator -gt 0) {
|
||||
[Environment]::SetEnvironmentVariable($line.Substring(0, $separator), $line.Substring($separator + 1), 'Process')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$project = switch ($Component) {
|
||||
'agent' { 'agent/src/Monitor.Agent' }
|
||||
'probe' { 'probe/src/Monitor.Probe' }
|
||||
'fleet-enroll' { 'fleet/tools/fleet-enroll' }
|
||||
}
|
||||
$output = Join-Path $root ".release\publish\$RuntimeIdentifier\$Component"
|
||||
$buildRoot = Join-Path $root ".release\build\$RuntimeIdentifier-$Component"
|
||||
$null = New-Item -ItemType Directory -Force -Path $output
|
||||
|
||||
Push-Location $backend
|
||||
try {
|
||||
& dotnet publish $project `
|
||||
-m:1 `
|
||||
-c Release `
|
||||
-r $RuntimeIdentifier `
|
||||
--self-contained true `
|
||||
-p:PublishAot=true `
|
||||
-p:StripSymbols=true `
|
||||
-p:DebugType=none `
|
||||
-p:DebugSymbols=false `
|
||||
--artifacts-path $buildRoot `
|
||||
-o $output
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "NativeAOT publish failed for $project ($RuntimeIdentifier)."
|
||||
}
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
Write-Output "built $Component for $RuntimeIdentifier"
|
||||
Reference in new issue
Block a user