Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ extends:

- template: templates/linux-cpu-packaging-pipeline.yml

- template: templates/mac-cpu-packaging-pipeline.yml
parameters:
AllowReleasedOpsetOnly: 1
DoESRP: true

- template: stages/nuget-combine-cuda-stage.yml
parameters:
CudaVersion: ${{ parameters.CudaVersion }}
Expand All @@ -143,3 +148,51 @@ extends:
PreReleaseVersionSuffixNumber: ${{ parameters.PreReleaseVersionSuffixNumber }}
CudaArchs: ${{ variables.CudaArchs }}
win_cudnn_home: ${{ variables.win_cudnn_home }}

- template: stages/nodejs-win-packaging-stage.yml
parameters:
IsReleaseBuild: ${{ parameters.IsReleaseBuild }}
ArtifactName: 'drop-onnxruntime-nodejs-win-x64'
StageName: 'Windows_Nodejs_Packaging_x64'
BuildCommand: >-
--build_nodejs
--build_shared_lib
--cmake_generator "Visual Studio 17 2022"
--enable_generic_interface
--enable_onnx_tests
--enable_wcos
--skip_submodule_sync
--use_dml
--use_telemetry
--use_webgpu
BuildArch: 'x64'
sln_platform: 'x64'
DoEsrp: true
PublishWebGpuBuildTools: true

- template: stages/nodejs-win-packaging-stage.yml
parameters:
IsReleaseBuild: ${{ parameters.IsReleaseBuild }}
ArtifactName: 'drop-onnxruntime-nodejs-win-arm64'
StageName: 'Windows_Nodejs_Packaging_arm64'
BuildCommand: >-
--arm64
--build_nodejs
--build_shared_lib
--cmake_generator "Visual Studio 17 2022"
--enable_generic_interface
--enable_onnx_tests
--enable_wcos
--skip_submodule_sync
--use_dml
--use_telemetry
--use_webgpu
BuildArch: 'x64'
sln_platform: 'arm64'
DoEsrp: true
DependsOnStageName: Windows_Nodejs_Packaging_x64

- template: stages/nodejs-npm-packaging-stage.yml
parameters:
IsReleaseBuild: ${{ parameters.IsReleaseBuild }}
PreReleaseVersionSuffixString: ${{ parameters.PreReleaseVersionSuffixString }}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ variables:
resources:
pipelines:
- pipeline: build
source: 'Zip-Nuget-Java-Nodejs Packaging Pipeline'
source: 'Nuget - Packaging - CUDA13'
trigger: true
branch: main
repositories:
Expand Down Expand Up @@ -98,11 +98,11 @@ extends:
runCodesignValidationInjection: false
timeoutInMinutes: 10
steps:
# This pipeline usually are triggered by Zip-Nuget-Java-Nodejs Packaging Pipeline,
# The NPM_packages is from Android_Java_API_AAR_Packaging_QNN, not from RN_CI
# This pipeline is triggered by the Nuget - Packaging - CUDA13 pipeline.
# The NPM_packages is from the Nodejs_Packaging stage.
- download: build
artifact: 'NPM_packages'
displayName: 'Download NPM_packages from Zip-Nuget-Java-Nodejs Packaging Pipeline Pipeline Artifact'
displayName: 'Download NPM_packages from CUDA 13 Packaging Pipeline Artifact'

- task: CopyFiles@2
inputs:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
parameters:
- name: IsReleaseBuild
type: boolean

- name: PreReleaseVersionSuffixString
displayName: Suffix added to pre-release package version. Only used if IsReleaseBuild is true. Denotes the type of pre-release package.
type: string
values:
- alpha
- beta
- rc
- none

stages:
- stage: Nodejs_Packaging
dependsOn:
- Setup
- Windows_Nodejs_Packaging_x64
- Windows_Nodejs_Packaging_arm64
- Linux_Nodejs_Packaging_x64
- Linux_C_API_Packaging_CPU
- MacOS_C_API_Packaging_CPU
condition: succeeded()
jobs:
- job: Nodejs_Packaging
workspace:
clean: all
pool:
name: 'onnxruntime-Win-CPU-VS2022-Latest'
os: windows
templateContext:
sdl:
codeSignValidation:
enabled: true
break: false
binskim:
enabled: true
scanOutputDirectoryOnly: true
outputs:
- output: pipelineArtifact
targetPath: $(Build.ArtifactStagingDirectory)
artifactName: 'NPM_packages'
variables:
${{ if and(parameters.IsReleaseBuild, eq(parameters.PreReleaseVersionSuffixString, 'none')) }}:
NpmPackagingMode: 'release'
${{ elseif and(parameters.IsReleaseBuild, eq(parameters.PreReleaseVersionSuffixString, 'rc')) }}:
NpmPackagingMode: 'rc'
${{ elseif not(parameters.IsReleaseBuild) }}:
NpmPackagingMode: 'dev'
${{ else }}: # IsReleaseBuild + beta, alpha, etc. We don't support those and those suffixes are deprecated.
NpmPackagingMode: '<INVALID/UNSUPPORTED COMBINATION>'

steps:
- checkout: self
submodules: true

- script: |
echo.>>.gitattributes
echo /js/** text=auto eol=lf>>.gitattributes
rd /s /q js
git checkout -- js/**
git checkout -- .gitattributes
workingDirectory: '$(Build.SourcesDirectory)'
displayName: 'Testing: force EOL to lf on windows for /js/**'

##################################################################
# Node.js binding artifacts preparation
#
# This stage prepares Node.js binding artifacts for publishing. The artifacts support the following platforms:
# - Windows x64 (CPU, DML, WebGPU)
# - Windows arm64 (CPU, DML, WebGPU)
# - Linux x64 (CPU, CUDA, TensorRT, WebGPU)
# - Linux arm64 (CPU only)
# - macOS arm64 (CPU, CoreML, WebGPU)
#
# File manifest:
# - Windows x64 (CPU, DML, WebGPU):
# dependency: Windows_Nodejs_Packaging_x64 (drop-onnxruntime-nodejs-win-x64)
# files:
# - onnxruntime_binding.node
# - onnxruntime.dll
# - DirectML.dll
# - dxil.dll
# - dxcompiler.dll
#
# - Windows arm64 (CPU, DML, WebGPU):
# dependency: Windows_Nodejs_Packaging_arm64 (drop-onnxruntime-nodejs-win-arm64)
# files:
# - onnxruntime_binding.node
# - onnxruntime.dll
# - DirectML.dll
# - dxil.dll
# - dxcompiler.dll
#
# - Linux x64 (CPU, CUDA, TensorRT, WebGPU):
# dependency: Linux_Nodejs_Packaging_x64 (drop-onnxruntime-nodejs-linux-x64)
# files:
# - onnxruntime_binding.node
# - libonnxruntime.so.1
# - libonnxruntime_providers_shared.so
# - libonnxruntime_providers_cuda.so
# - libonnxruntime_providers_tensorrt.so
#
# - Linux arm64 (CPU only):
# stage: Linux_C_API_Packaging_CPU, job: Linux_C_API_Packaging_CPU_aarch64 (drop-onnxruntime-nodejs-linux-aarch64)
# files:
# - onnxruntime_binding.node
# - libonnxruntime.so.1
#
# - macOS arm64 (CPU, CoreML, WebGPU):
# stage: MacOS_C_API_Packaging_CPU, job: MacOS_C_API_Packaging_CPU_arm64 (drop-onnxruntime-nodejs-osx-arm64)
# files:
# - onnxruntime_binding.node
# - libonnxruntime.{version}.dylib
#
# The following files will be excluded from the further packaging because they are too large to be included in the
# NPM package:
# - linux/x64/libonnxruntime_providers_cuda.so
#
# Rest binary artifacts will eventually be put into folder before packaging 'onnxruntime-node':
# $(Build.SourcesDirectory)\js\node\bin\napi-v6\{os}\{cpu_arch}\
#
# {os} is one of 'win32', 'darwin', 'linux' and {cpu_arch} is one of 'x64', 'arm64'.

- task: DownloadPipelineArtifact@0
displayName: 'Download Pipeline Artifact - Nodejs (Win x64)'
inputs:
artifactName: 'drop-onnxruntime-nodejs-win-x64'
targetPath: '$(Build.BinariesDirectory)/nodejs-artifacts/win32/x64/'

- task: DownloadPipelineArtifact@0
displayName: 'Download Pipeline Artifact - Nodejs (Win ARM64)'
inputs:
artifactName: 'drop-onnxruntime-nodejs-win-arm64'
targetPath: '$(Build.BinariesDirectory)/nodejs-artifacts/win32/arm64/'

- task: DownloadPipelineArtifact@0
displayName: 'Download Pipeline Artifact - Nodejs (macOS arm64)'
inputs:
artifactName: 'drop-onnxruntime-nodejs-osx-arm64'
targetPath: '$(Build.BinariesDirectory)/nodejs-artifacts/darwin/arm64/'

- task: DownloadPipelineArtifact@0
displayName: 'Download Pipeline Artifact - Nodejs (Linux x64)'
inputs:
artifactName: 'drop-onnxruntime-nodejs-linux-x64'
targetPath: '$(Build.BinariesDirectory)/nodejs-artifacts/linux/x64/'

- task: DownloadPipelineArtifact@0
displayName: 'Download Pipeline Artifact - Nodejs (Linux aarch64)'
inputs:
artifactName: 'drop-onnxruntime-nodejs-linux-aarch64'
targetPath: '$(Build.BinariesDirectory)/nodejs-artifacts/linux/arm64/'

- script: |
dir /S
workingDirectory: '$(Build.BinariesDirectory)/nodejs-artifacts'
displayName: 'List artifacts'

- script: |
npm ci
workingDirectory: '$(Build.SourcesDirectory)/js'
displayName: 'Install NPM packages /js'
- script: |
npm ci
workingDirectory: '$(Build.SourcesDirectory)/js/common'
displayName: 'Install NPM packages /js/common'
- script: |
npm ci
workingDirectory: '$(Build.SourcesDirectory)/js/node'
displayName: 'Install NPM packages /js/node'

# Node.js binding win32/x64
- task: CopyFiles@2
displayName: 'Copy binaries to: $(Build.SourcesDirectory)\js\node\bin\napi-v6\win32\x64\'
inputs:
SourceFolder: '$(Build.BinariesDirectory)\nodejs-artifacts\win32\x64'
Contents: |
*.dll
*.node
TargetFolder: '$(Build.SourcesDirectory)\js\node\bin\napi-v6\win32\x64'

# Node.js binding win32/arm64
- task: CopyFiles@2
displayName: 'Copy binaries to: $(Build.SourcesDirectory)\js\node\bin\napi-v6\win32\arm64\'
inputs:
SourceFolder: '$(Build.BinariesDirectory)\nodejs-artifacts\win32\arm64'
Contents: |
*.dll
*.node
TargetFolder: '$(Build.SourcesDirectory)\js\node\bin\napi-v6\win32\arm64'

# Node.js binding linux/x64
- task: CopyFiles@2
displayName: 'Copy nodejs binaries to: $(Build.SourcesDirectory)\js\node\bin\napi-v6\linux\x64\'
inputs:
SourceFolder: '$(Build.BinariesDirectory)\nodejs-artifacts\linux\x64'
Contents: |
libonnxruntime.so.1
*.node
TargetFolder: '$(Build.SourcesDirectory)\js\node\bin\napi-v6\linux\x64'

# Node.js binding linux/arm64
- task: CopyFiles@2
displayName: 'Copy nodejs binaries to: $(Build.SourcesDirectory)\js\node\bin\napi-v6\linux\arm64\'
inputs:
SourceFolder: '$(Build.BinariesDirectory)\nodejs-artifacts\linux\arm64'
Contents: |
libonnxruntime.so.1
*.node
TargetFolder: '$(Build.SourcesDirectory)\js\node\bin\napi-v6\linux\arm64'

# Node.js binding darwin/arm64
- task: CopyFiles@2
displayName: 'Copy nodejs binaries to: $(Build.SourcesDirectory)\js\node\bin\napi-v6\darwin\arm64\'
inputs:
SourceFolder: '$(Build.BinariesDirectory)\nodejs-artifacts\darwin\arm64'
Contents: |
libonnxruntime.*.dylib
*.node
TargetFolder: '$(Build.SourcesDirectory)\js\node\bin\napi-v6\darwin\arm64'

- ${{ if not(eq(parameters.IsReleaseBuild, true)) }}:
- task: PowerShell@2
displayName: 'Set environment variable NODEJS_DEP_PACKAGE_VERSIONS'
inputs:
targetType: 'inline'
script: |
# The following PowerShell script is used to set environment variable "NODEJS_DEP_PACKAGE_VERSIONS" to the
# following format:
# <current_version>;<latest_existing_version>
#
# - The "current_version" is the same to the version of the Nuget package being built.
# - The "latest_existing_version" is the latest existing version of the package
# "Microsoft.ML.OnnxRuntime.Gpu.Linux" from the NuGet nightly feed.
#

$index = 'https://aiinfra.pkgs.visualstudio.com/PublicPackages/_packaging/ORT-Nightly/nuget/v3/index.json'
$packageName = 'Microsoft.ML.OnnxRuntime.Gpu.Linux'

# Download NuGet index
$nugetIndex = Invoke-RestMethod -Uri $index -UseBasicParsing
if (-not $nugetIndex) {
throw "Failed to download NuGet index from $index"
}

# Find the base URL for "PackageBaseAddress/3.0.0"
$packageBaseUrl = ($nugetIndex.resources | Where-Object { $_.'@type' -eq 'PackageBaseAddress/3.0.0' }).'@id'
if (-not $packageBaseUrl) {
throw "Failed to find PackageBaseAddress in NuGet index"
}

# Fetch package version info
$packageInfo = Invoke-RestMethod -Uri "$packageBaseUrl$($packageName.ToLower())/index.json" -UseBasicParsing
if (-not $packageInfo.versions -or $packageInfo.versions.Count -eq 0) {
throw "No versions found for package $packageName"
}

# Extract the latest dev version (NuGet index.json returns versions in ascending order)
$devVersions = @($packageInfo.versions | Where-Object { $_ -match '-dev-' })
if ($devVersions.Count -eq 0) {
throw "No dev versions found for package $packageName"
}
$latestVersion = $devVersions[-1]
Write-Host "Latest version of ${packageName}: $latestVersion"

# Generate current version
$currentVersion = "$(cat .\VERSION_NUMBER)-dev-$($env:ORT_CI_BUILD_DATE)-$($env:ORT_CI_BUILD_TIME)-$(git rev-parse --short HEAD)"
Write-Host "Current version: $currentVersion"

# Set the version as an environment variable
Write-Host "##vso[task.setvariable variable=NODEJS_DEP_PACKAGE_VERSIONS]$currentVersion;$latestVersion"
Write-Host "Environment variable NODEJS_DEP_PACKAGE_VERSIONS set to $currentVersion;$latestVersion"
workingDirectory: '$(Build.SourcesDirectory)'

- task: PowerShell@2
inputs:
filePath: '$(Build.SourcesDirectory)\tools\ci_build\github\js\pack-npm-packages.ps1'
arguments: '$(NpmPackagingMode) "$(Build.SourcesDirectory)" node "$env:NODEJS_DEP_PACKAGE_VERSIONS"'
workingDirectory: $(Build.BinariesDirectory)
errorActionPreference: stop
displayName: 'Pack NPM packages'

- task: CopyFiles@2
displayName: 'Copy onnxruntime-common package to staging directory'
inputs:
SourceFolder: '$(Build.SourcesDirectory)/js/common/'
Contents: 'onnxruntime-common-*.tgz'
TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: CopyFiles@2
displayName: 'Copy onnxruntime-node package to staging directory'
inputs:
SourceFolder: '$(Build.SourcesDirectory)/js/node/'
Contents: 'onnxruntime-node-*.tgz'
TargetFolder: '$(Build.ArtifactStagingDirectory)'
Loading
Loading