onnxruntime/tools/ci_build/github/azure-pipelines/templates/publish-nuget.yml
2023-03-24 23:39:15 -07:00

100 lines
4.7 KiB
YAML

parameters:
- name: PublishingNuget
displayName: Publishing Nuget Packages and report binary size to mysql
type: boolean
default: true
stages:
- stage: Publish_NuGet_Package_And_Report
condition: and (succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
dependsOn:
- NuGet_Test_Win_CPU
- NuGet_Test_Linux_CPU
- NuGet_Test_Win_GPU
- NuGet_Test_Linux_GPU
- NuGet_Test_MacOS
- NuGet_Packaging_DML
jobs:
- job:
workspace:
clean: all
variables:
- name: GDN_CODESIGN_TARGETDIRECTORY
value: '$(Build.BinariesDirectory)/nuget-artifact/final-package'
pool: 'Win-CPU-2021'
steps:
- checkout: self
submodules: false
- template: set-version-number-variables-step.yml
- task: DownloadPipelineArtifact@0
displayName: 'Download Pipeline Artifact - Signed NuGet Package'
inputs:
artifactName: 'drop-signed-nuget-CPU'
targetPath: $(Build.BinariesDirectory)/nuget-artifact/final-package
- template: ../nuget/templates/get-nuget-package-version-as-variable.yml
parameters:
packageFolder: '$(Build.BinariesDirectory)/nuget-artifact/final-package'
- task: CmdLine@2
displayName: 'Post binary sizes to the dashboard database using command line'
inputs:
script: |
echo changing directory to artifact download path
cd $(Build.BinariesDirectory)/nuget-artifact/final-package
echo processing nupkg
SETLOCAL EnableDelayedExpansion
FOR /R %%i IN (*.nupkg) do (
set filename=%%~ni
IF NOT "!filename:~25,7!"=="Managed" (
echo processing %%~ni.nupkg
copy %%~ni.nupkg %%~ni.zip
echo copied to zip
echo listing lib files in the zip
REM use a single .csv file to put the data
echo os,arch,build_config,size > $(Build.BinariesDirectory)\binary_size_data.txt
7z.exe l -slt %%~ni.zip runtimes\linux-arm64\native\libonnxruntime.so | findstr /R /C:"^Size = [0-9]*" | for /F "tokens=3" %%a in ('more') do if not "%%a" == "" echo linux,aarch64,default,%%a >> $(Build.BinariesDirectory)\binary_size_data.txt
7z.exe l -slt %%~ni.zip runtimes\osx.10.14-x64\native\libonnxruntime.dylib | findstr /R /C:"^Size = [0-9]*" | for /F "tokens=3" %%a in ('more') do if not "%%a" == "" echo osx,x64,default,%%a >> $(Build.BinariesDirectory)\binary_size_data.txt
7z.exe l -slt %%~ni.zip runtimes\win-x64\native\onnxruntime.dll | findstr /R /C:"^Size = [0-9]*" | for /F "tokens=3" %%a in ('more') do if not "%%a" == "" echo win,x64,default,%%a >> $(Build.BinariesDirectory)\binary_size_data.txt
7z.exe l -slt %%~ni.zip runtimes\win-x86\native\onnxruntime.dll | findstr /R /C:"^Size = [0-9]*" | for /F "tokens=3" %%a in ('more') do if not "%%a" == "" echo win,x86,default,%%a >> $(Build.BinariesDirectory)\binary_size_data.txt
)
)
- task: AzureCLI@2
displayName: 'Azure CLI'
inputs:
azureSubscription: AIInfraBuildOnnxRuntimeOSS
scriptLocation: inlineScript
scriptType: batch
inlineScript: |
python.exe -m pip install -r $(Build.SourcesDirectory)\tools\ci_build\github\windows\post_to_dashboard\requirements.txt && ^
python.exe $(Build.SourcesDirectory)\tools\ci_build\github\windows\post_binary_sizes_to_dashboard.py --commit_hash=$(Build.SourceVersion) --size_data_file=binary_size_data.txt --build_project=Lotus --build_id=$(Build.BuildId)
workingDirectory: '$(Build.BinariesDirectory)'
- task: DownloadPipelineArtifact@0
displayName: 'Download Pipeline Artifact - Signed NuGet Package'
inputs:
artifactName: 'drop-signed-nuget-dml'
targetPath: $(Build.BinariesDirectory)/nuget-artifact/final-package
- task: DownloadPipelineArtifact@0
displayName: 'Download Pipeline Artifact - Signed NuGet Package'
inputs:
artifactName: 'drop-signed-nuget-GPU'
targetPath: $(Build.BinariesDirectory)/nuget-artifact/final-package
- task: NuGetCommand@2
displayName: 'Copy Signed Native NuGet Package to ORT-NIGHTLY'
condition: ne(variables['IsReleaseBuild'], 'true') # release build has a different package naming scheme
inputs:
command: 'push'
packagesToPush: '$(Build.BinariesDirectory)/nuget-artifact/final-package/*.nupkg'
publishVstsFeed: '2692857e-05ef-43b4-ba9c-ccf1c22c437c/7982ae20-ed19-4a35-a362-a96ac99897b7'
- template: component-governance-component-detection-steps.yml
parameters :
condition : 'succeeded'
- task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3
displayName: 'Clean Agent Directories'
condition: always()