Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 111 additions & 73 deletions .pipelines/foundry-local-packaging.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Foundry Local Packaging Pipeline
#
# Builds Foundry Local Core from neutron-server (windows.ai.toolkit project),
# then packages the C# and JS SDKs from this repo using the built Core.
# then packages the SDKs from this repo using the built Core.
#
# Produces artifacts: flc-nuget, flc-nuget-winml, flc-wheels, flc-wheels-winml,
# cs-sdk, cs-sdk-winml, js-sdk, js-sdk-winml, python-sdk, python-sdk-winml,
Expand All @@ -14,18 +14,6 @@ pr:
name: $(Date:yyyyMMdd).$(Rev:r)

parameters:
- name: version
displayName: 'Package version'
type: string
default: '1.2.0'
- name: prereleaseId
displayName: 'Pre-release identifier (e.g. rc1, beta).'
type: string
default: 'none'
- name: isRelease
displayName: 'Release build'
type: boolean
default: false
- name: neutronServerBranch
displayName: 'Foundry Local Core branch (windows.ai.toolkit/neutron-server)'
type: string
Expand Down Expand Up @@ -55,19 +43,18 @@ extends:
break: false
scanOutputDirectoryOnly: true
stages:
# ── Compute Version ──
# A single version string is computed once and shared across all stages.
# This prevents timestamp drift between standard and WinML builds.
# Outputs three format variants:
# sdkVersion – semver for JS, C#, Rust (e.g. X.Y.Z-dev.202604061234)
# pyVersion – PEP 440 for Python (e.g. X.Y.Z.dev202604061234)
# flcVersion – NuGet/FLC style (e.g. X.Y.Z-dev-202604061234-ab12cd34)
# ── Resolve Package Versions ──
# Package versions come from the Core dependency versions committed under sdk/.
# This keeps SDK package versions aligned with the Core packages they consume:
# sdkVersion – NuGet/SemVer version for JS, C#, Rust
# pyVersion – PEP 440 version for Python
# flcVersion – NuGet/FLC package version
- stage: compute_version
displayName: 'Compute Version'
displayName: 'Resolve Package Versions'
dependsOn: []
jobs:
- job: version
displayName: 'Compute Version'
displayName: 'Resolve Package Versions'
pool:
name: onnxruntime-Win-CPU-2022
os: windows
Expand All @@ -77,36 +64,93 @@ extends:
artifactName: 'version-info'
targetPath: '$(Build.ArtifactStagingDirectory)/version-info'
steps:
- checkout: none
- checkout: self
- task: PowerShell@2
displayName: 'Compute and write version files'
displayName: 'Resolve versions from SDK dependency files'
inputs:
targetType: inline
script: |
$base = "${{ parameters.version }}"
$preId = "${{ parameters.prereleaseId }}"
$ts = Get-Date -Format "yyyyMMddHHmm"
$commitId = "$(Build.SourceVersion)".Substring(0, 8)
$ErrorActionPreference = 'Stop'

function Get-CoreVersions {
param(
[Parameter(Mandatory=$true)][string]$Path,
[Parameter(Mandatory=$true)][string]$Label
)

if (-not (Test-Path $Path)) {
throw "$Label dependency version file not found: $Path"
}

$deps = Get-Content $Path -Raw | ConvertFrom-Json
$core = $deps.'foundry-local-core'
if ($null -eq $core) {
throw "$Label dependency version file is missing foundry-local-core: $Path"
}

$nugetVersion = [string]$core.nuget
$pythonVersion = [string]$core.python
if ([string]::IsNullOrWhiteSpace($nugetVersion)) {
throw "$Label dependency version file has empty foundry-local-core.nuget: $Path"
}
if ([string]::IsNullOrWhiteSpace($pythonVersion)) {
throw "$Label dependency version file has empty foundry-local-core.python: $Path"
}

return [pscustomobject]@{
NuGet = $nugetVersion.Trim()
Python = $pythonVersion.Trim()
}
}

$repoRoot = "$(Build.SourcesDirectory)"
$standardCore = Get-CoreVersions `
-Path (Join-Path $repoRoot "sdk/deps_versions.json") `
-Label "Standard"
$winmlCore = Get-CoreVersions `
-Path (Join-Path $repoRoot "sdk/deps_versions_winml.json") `
-Label "WinML"

if ($preId -ne '' -and $preId -ne 'none') {
$sdkVersion = "$base-$preId"
$pyVersion = "$base$preId"
$flcVersion = "$base-$preId"
} elseif ("${{ parameters.isRelease }}" -ne "True") {
$sdkVersion = "$base-dev.$ts"
$pyVersion = "$base.dev$ts"
$flcVersion = "$base-dev-$ts-$commitId"
} else {
$sdkVersion = $base
$pyVersion = $base
$flcVersion = $base
if ($standardCore.NuGet -ne $winmlCore.NuGet) {
throw "Core NuGet versions must match in sdk/deps_versions.json and sdk/deps_versions_winml.json. Standard: $($standardCore.NuGet); WinML: $($winmlCore.NuGet)"
}
if ($standardCore.Python -ne $winmlCore.Python) {
throw "Core Python versions must match in sdk/deps_versions.json and sdk/deps_versions_winml.json. Standard: $($standardCore.Python); WinML: $($winmlCore.Python)"
}

$sdkVersion = $standardCore.NuGet
$flcVersion = $standardCore.NuGet
$pyVersion = $standardCore.Python

foreach ($entry in @(
@{ Name = "SDK version"; Value = $sdkVersion },
@{ Name = "Python version"; Value = $pyVersion },
@{ Name = "FLC version"; Value = $flcVersion }
)) {
if ([string]::IsNullOrWhiteSpace($entry.Value)) {
throw "$($entry.Name) was empty"
}
}

$outDir = "$(Build.ArtifactStagingDirectory)/version-info"
New-Item -ItemType Directory -Path $outDir -Force | Out-Null
Set-Content -Path "$outDir/sdkVersion.txt" -Value $sdkVersion -NoNewline
Set-Content -Path "$outDir/pyVersion.txt" -Value $pyVersion -NoNewline
Set-Content -Path "$outDir/flcVersion.txt" -Value $flcVersion -NoNewline

$utf8NoBom = [System.Text.UTF8Encoding]::new($false)
[System.IO.File]::WriteAllText("$outDir/sdkVersion.txt", $sdkVersion, $utf8NoBom)
[System.IO.File]::WriteAllText("$outDir/pyVersion.txt", $pyVersion, $utf8NoBom)
[System.IO.File]::WriteAllText("$outDir/flcVersion.txt", $flcVersion, $utf8NoBom)

$versions = [ordered]@{
sdkVersion = $sdkVersion
pythonVersion = $pyVersion
flcVersion = $flcVersion
source = "sdk/deps_versions.json"
standardCoreNuGetPackageVersion = $standardCore.NuGet
standardCorePythonPackageVersion = $standardCore.Python
winmlCoreNuGetPackageVersion = $winmlCore.NuGet
winmlCorePythonPackageVersion = $winmlCore.Python
} | ConvertTo-Json
[System.IO.File]::WriteAllText("$outDir/versions.json", $versions, $utf8NoBom)

Write-Host "SDK version: $sdkVersion"
Write-Host "Python version: $pyVersion"
Expand All @@ -123,6 +167,10 @@ extends:
name: onnxruntime-Win-CPU-2022
os: windows
templateContext:
inputs:
- input: pipelineArtifact
artifactName: 'version-info'
targetPath: '$(Pipeline.Workspace)/version-info'
outputs:
- output: pipelineArtifact
artifactName: 'flc-win-x64'
Expand All @@ -146,6 +194,10 @@ extends:
name: onnxruntime-Win-CPU-2022
os: windows
templateContext:
inputs:
- input: pipelineArtifact
artifactName: 'version-info'
targetPath: '$(Pipeline.Workspace)/version-info'
outputs:
- output: pipelineArtifact
artifactName: 'flc-win-arm64'
Expand All @@ -169,6 +221,10 @@ extends:
name: onnxruntime-Ubuntu2404-AMD-CPU
os: linux
templateContext:
inputs:
- input: pipelineArtifact
artifactName: 'version-info'
targetPath: '$(Pipeline.Workspace)/version-info'
outputs:
- output: pipelineArtifact
artifactName: 'flc-linux-x64'
Expand All @@ -194,6 +250,10 @@ extends:
demands:
- ImageOverride -equals ACES_VM_SharedPool_Sequoia
templateContext:
inputs:
- input: pipelineArtifact
artifactName: 'version-info'
targetPath: '$(Pipeline.Workspace)/version-info'
outputs:
- output: pipelineArtifact
artifactName: 'flc-osx-arm64'
Expand Down Expand Up @@ -277,9 +337,6 @@ extends:
}
- template: .pipelines/templates/package-core-steps.yml@self
parameters:
version: ${{ parameters.version }}
isRelease: ${{ parameters.isRelease }}
prereleaseId: ${{ parameters.prereleaseId }}
isWinML: false
platforms:
- name: win-x64
Expand Down Expand Up @@ -324,9 +381,6 @@ extends:
repoName: test-data-shared
- template: .pipelines/templates/build-cs-steps.yml@self
parameters:
version: ${{ parameters.version }}
isRelease: ${{ parameters.isRelease }}
prereleaseId: ${{ parameters.prereleaseId }}
isWinML: false
flcNugetDir: '$(Pipeline.Workspace)/flc-nuget'
depsVersionsDir: '$(Pipeline.Workspace)/deps-versions-standard'
Expand Down Expand Up @@ -512,9 +566,6 @@ extends:

- template: .pipelines/templates/build-js-steps.yml@self
parameters:
version: ${{ parameters.version }}
isRelease: ${{ parameters.isRelease }}
prereleaseId: ${{ parameters.prereleaseId }}
isWinML: false
flcNugetDir: '$(Pipeline.Workspace)/flc-nuget'
depsVersionsDir: '$(Pipeline.Workspace)/deps-versions-standard'
Expand Down Expand Up @@ -552,9 +603,6 @@ extends:
repoName: test-data-shared
- template: .pipelines/templates/build-python-steps.yml@self
parameters:
version: ${{ parameters.version }}
isRelease: ${{ parameters.isRelease }}
prereleaseId: ${{ parameters.prereleaseId }}
isWinML: false
flcWheelsDir: '$(Pipeline.Workspace)/flc-wheels'
depsVersionsDir: '$(Pipeline.Workspace)/deps-versions-standard'
Expand Down Expand Up @@ -592,9 +640,6 @@ extends:
repoName: test-data-shared
- template: .pipelines/templates/build-rust-steps.yml@self
parameters:
version: ${{ parameters.version }}
isRelease: ${{ parameters.isRelease }}
prereleaseId: ${{ parameters.prereleaseId }}
isWinML: false
flcNugetDir: '$(Pipeline.Workspace)/flc-nuget'
depsVersionsDir: '$(Pipeline.Workspace)/deps-versions-standard'
Expand Down Expand Up @@ -635,9 +680,6 @@ extends:
# lfs: true
# - template: .pipelines/templates/build-rust-steps.yml@self
# parameters:
# version: ${{ parameters.version }}
# isRelease: ${{ parameters.isRelease }}
# prereleaseId: ${{ parameters.prereleaseId }}
# isWinML: true
# flcNugetDir: '$(Pipeline.Workspace)/flc-nuget-winml'
# depsVersionsDir: '$(Pipeline.Workspace)/deps-versions-winml'
Expand Down Expand Up @@ -1011,6 +1053,10 @@ extends:
name: onnxruntime-Win-CPU-2022
os: windows
templateContext:
inputs:
- input: pipelineArtifact
artifactName: 'version-info'
targetPath: '$(Pipeline.Workspace)/version-info'
outputs:
- output: pipelineArtifact
artifactName: 'flc-winml-win-x64'
Expand All @@ -1035,6 +1081,10 @@ extends:
name: onnxruntime-Win-CPU-2022
os: windows
templateContext:
inputs:
- input: pipelineArtifact
artifactName: 'version-info'
targetPath: '$(Pipeline.Workspace)/version-info'
outputs:
- output: pipelineArtifact
artifactName: 'flc-winml-win-arm64'
Expand Down Expand Up @@ -1104,9 +1154,6 @@ extends:
}
- template: .pipelines/templates/package-core-steps.yml@self
parameters:
version: ${{ parameters.version }}
isRelease: ${{ parameters.isRelease }}
prereleaseId: ${{ parameters.prereleaseId }}
isWinML: true
platforms:
- name: win-x64
Expand Down Expand Up @@ -1147,9 +1194,6 @@ extends:
repoName: test-data-shared
- template: .pipelines/templates/build-cs-steps.yml@self
parameters:
version: ${{ parameters.version }}
isRelease: ${{ parameters.isRelease }}
prereleaseId: ${{ parameters.prereleaseId }}
isWinML: true
flcNugetDir: '$(Pipeline.Workspace)/flc-nuget-winml'
depsVersionsDir: '$(Pipeline.Workspace)/deps-versions-winml'
Expand Down Expand Up @@ -1232,9 +1276,6 @@ extends:

- template: .pipelines/templates/build-js-steps.yml@self
parameters:
version: ${{ parameters.version }}
isRelease: ${{ parameters.isRelease }}
prereleaseId: ${{ parameters.prereleaseId }}
isWinML: true
flcNugetDir: '$(Pipeline.Workspace)/flc-nuget-winml'
depsVersionsDir: '$(Pipeline.Workspace)/deps-versions-winml'
Expand Down Expand Up @@ -1272,9 +1313,6 @@ extends:
repoName: test-data-shared
- template: .pipelines/templates/build-python-steps.yml@self
parameters:
version: ${{ parameters.version }}
isRelease: ${{ parameters.isRelease }}
prereleaseId: ${{ parameters.prereleaseId }}
isWinML: true
flcWheelsDir: '$(Pipeline.Workspace)/flc-wheels-winml'
depsVersionsDir: '$(Pipeline.Workspace)/deps-versions-winml'
Expand Down
10 changes: 1 addition & 9 deletions .pipelines/templates/build-cs-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
# When test-data-shared is checked out alongside self, ADO places repos under
# $(Build.SourcesDirectory)/<repo-name>. The self repo is 'Foundry-Local'.
parameters:
- name: version
type: string
- name: isRelease
type: boolean
default: false
- name: isWinML
type: boolean
default: false
Expand All @@ -17,9 +12,6 @@ parameters:
type: string
default: '$(Build.ArtifactStagingDirectory)/cs-sdk'
displayName: 'Path to directory for the packed SDK'
- name: prereleaseId
type: string
default: ''
- name: depsVersionsDir
type: string
default: ''
Expand Down Expand Up @@ -49,7 +41,7 @@ steps:
packageType: sdk
version: '10.0.x'

# Read version from the version-info artifact produced by compute_version stage.
# Read package version resolved from the SDK dependency version files.
- task: PowerShell@2
displayName: 'Set package version'
inputs:
Expand Down
10 changes: 1 addition & 9 deletions .pipelines/templates/build-js-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@
# When test-data-shared is checked out alongside self, ADO places repos under
# $(Build.SourcesDirectory)/<repo-name>. The self repo is 'Foundry-Local'.
parameters:
- name: version
type: string
- name: isRelease
type: boolean
default: false
- name: isWinML
type: boolean
default: false
- name: flcNugetDir
type: string
default: ''
displayName: 'Path to directory containing the FLC .nupkg (for tests)'
- name: prereleaseId
type: string
default: ''
- name: depsVersionsDir
type: string
default: ''
Expand Down Expand Up @@ -61,7 +53,7 @@ steps:
artifactDir: ${{ parameters.depsVersionsDir }}
isWinML: ${{ parameters.isWinML }}

# Compute version
# Read package version resolved from the SDK dependency version files.
- task: PowerShell@2
displayName: 'Set package version'
inputs:
Expand Down
Loading