microsoft/onnxruntime-extensions
Publicmirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable
.pipelines/templates/build-package-for-nuget.yml
280lines · modecode
| 1 | parameters: |
| 2 | - name: DoCompliance |
| 3 | displayName: Run Compliance Tasks? |
| 4 | type: boolean |
| 5 | default: true |
| 6 | |
| 7 | - name: DoEsrp |
| 8 | displayName: Run code sign tasks? Must be true if you are doing an OnnxRuntime extensions release. |
| 9 | type: boolean |
| 10 | default: false |
| 11 | |
| 12 | - name: IsReleaseBuild |
| 13 | displayName: Is a release build? |
| 14 | type: boolean |
| 15 | default: false |
| 16 | |
| 17 | - name: IsDummyPackage |
| 18 | displayName: Is this a build of Microsoft.ML.OnnxRuntime.Extensions.Dummy package that has no operators? |
| 19 | type: boolean |
| 20 | default: false |
| 21 | |
| 22 | - name: NugetVersionSuffix |
| 23 | displayName: Nuget version suffix |
| 24 | type: string |
| 25 | |
| 26 | - name: OperatorSelectionFlags |
| 27 | displayName: Flags to select operators included. Default is to disable OCOS_ENABLE_CV2 and OCOS_ENABLE_BLINGFIRE |
| 28 | type: string |
| 29 | default: '--cmake_extra_defines OCOS_ENABLE_CV2=OFF OCOS_ENABLE_BLINGFIRE=OFF' |
| 30 | |
| 31 | - name: AdditionalBuildFlags |
| 32 | displayName: Additional build flags. |
| 33 | type: string |
| 34 | default: '' |
| 35 | |
| 36 | stages: |
| 37 | # MacOS_C_API_Packaging_CPU |
| 38 | - template: build-package-for-macosx.yml |
| 39 | parameters: |
| 40 | IsReleaseBuild: ${{ parameters.IsReleaseBuild }} |
| 41 | AdditionalBuildFlags: ${{parameters.OperatorSelectionFlags}} ${{parameters.AdditionalBuildFlags}} |
| 42 | |
| 43 | - stage: Linux_C_API_Packaging_CPU |
| 44 | dependsOn: [] |
| 45 | jobs: |
| 46 | - template: build-package-for-linux.yml |
| 47 | parameters: |
| 48 | OrtExtensionsArch: 'x64' |
| 49 | PoolName: 'onnxruntime-Ubuntu2204-AMD-CPU' |
| 50 | IsReleaseBuild: ${{parameters.IsReleaseBuild}} |
| 51 | OrtExtensionsCFlags: '' |
| 52 | OrtExtensionsCXXFlags: '' |
| 53 | AdditionalBuildFlags: ${{parameters.OperatorSelectionFlags}} ${{parameters.AdditionalBuildFlags}} |
| 54 | |
| 55 | - template: build-package-for-linux.yml |
| 56 | parameters: |
| 57 | OrtExtensionsArch: 'aarch64' |
| 58 | PoolName: 'onnxruntime-linux-ARM64-CPU-2019' |
| 59 | IsReleaseBuild: ${{parameters.IsReleaseBuild}} |
| 60 | OrtExtensionsCFlags: '' |
| 61 | OrtExtensionsCXXFlags: '' |
| 62 | AdditionalBuildFlags: ${{parameters.OperatorSelectionFlags}} ${{parameters.AdditionalBuildFlags}} |
| 63 | |
| 64 | - stage: Windows_C_API_Packaging_CPU |
| 65 | dependsOn: [] |
| 66 | jobs: |
| 67 | - template: build-package-for-windows.yml |
| 68 | parameters: |
| 69 | DoCompliance: ${{ parameters.DoCompliance }} |
| 70 | DoEsrp: ${{ parameters.DoEsrp }} |
| 71 | StageNameSuffix: CPU_x86 |
| 72 | # Win32 |
| 73 | BuildPlatform: x86 |
| 74 | AdditionalBuildFlags: ${{parameters.OperatorSelectionFlags}} ${{parameters.AdditionalBuildFlags}} |
| 75 | |
| 76 | - template: build-package-for-windows.yml |
| 77 | parameters: |
| 78 | DoCompliance: ${{ parameters.DoCompliance }} |
| 79 | DoEsrp: ${{ parameters.DoEsrp }} |
| 80 | StageNameSuffix: CPU_arm64 |
| 81 | BuildPlatform: arm64 |
| 82 | AdditionalBuildFlags: ${{parameters.OperatorSelectionFlags}} ${{parameters.AdditionalBuildFlags}} |
| 83 | |
| 84 | - template: build-package-for-windows.yml |
| 85 | parameters: |
| 86 | DoCompliance: ${{ parameters.DoCompliance }} |
| 87 | DoEsrp: ${{ parameters.DoEsrp }} |
| 88 | StageNameSuffix: CPU_x64 |
| 89 | BuildPlatform: 'x64' |
| 90 | AdditionalBuildFlags: ${{parameters.OperatorSelectionFlags}} ${{parameters.AdditionalBuildFlags}} |
| 91 | |
| 92 | #Android_Java_API_AAR_Packaging_Full |
| 93 | - template: build-package-for-android-aar.yml |
| 94 | parameters: |
| 95 | IsReleaseBuild: ${{ parameters.IsReleaseBuild }} |
| 96 | AdditionalBuildFlags: ${{parameters.OperatorSelectionFlags}} ${{parameters.AdditionalBuildFlags}} |
| 97 | |
| 98 | - stage: iOS_Full_xcframework |
| 99 | dependsOn: [] |
| 100 | jobs: |
| 101 | - template: build-package-for-ios-cocoapods.yml |
| 102 | parameters: |
| 103 | IsReleaseBuild: ${{ parameters.IsReleaseBuild }} |
| 104 | AdditionalBuildFlags: ${{parameters.OperatorSelectionFlags}} ${{parameters.AdditionalBuildFlags}} |
| 105 | |
| 106 | |
| 107 | - stage: NuGet_Packaging_CPU |
| 108 | dependsOn: |
| 109 | - Linux_C_API_Packaging_CPU |
| 110 | - Windows_C_API_Packaging_CPU |
| 111 | - MacOS_C_API_Packaging_CPU |
| 112 | - Android_Java_API_AAR_Packaging_Full |
| 113 | - iOS_Full_xcframework |
| 114 | condition: succeeded() |
| 115 | jobs: |
| 116 | - job: Nuget_Packaging |
| 117 | workspace: |
| 118 | clean: all |
| 119 | # we need to use the 2022 pool to create the nuget package with both pre-net6+Xamarin and net6 targets. |
| 120 | # VS2019 has no support for net6 and we need to use msbuild (from the VS install) to do the packing |
| 121 | pool: 'onnxruntime-Win-CPU-2022' |
| 122 | variables: |
| 123 | breakCodesignValidationInjection: ${{ parameters.DoEsrp }} |
| 124 | |
| 125 | steps: |
| 126 | - checkout: self |
| 127 | submodules: true |
| 128 | |
| 129 | - task: UsePythonVersion@0 |
| 130 | inputs: |
| 131 | versionSpec: "3.9" |
| 132 | addToPath: true |
| 133 | architecture: "x64" |
| 134 | displayName: "Use Python 3.9" |
| 135 | |
| 136 | - task: DownloadPipelineArtifact@0 |
| 137 | displayName: 'Download win-x64 Pipeline Artifact' |
| 138 | inputs: |
| 139 | artifactName: 'onnxruntime-extensions-win-x64' |
| 140 | targetPath: '$(Build.BinariesDirectory)/artifact-downloads' |
| 141 | |
| 142 | - task: DownloadPipelineArtifact@0 |
| 143 | displayName: 'Download win-x86 Pipeline Artifact' |
| 144 | inputs: |
| 145 | artifactName: 'onnxruntime-extensions-win-x86' |
| 146 | targetPath: '$(Build.BinariesDirectory)/artifact-downloads' |
| 147 | |
| 148 | - task: DownloadPipelineArtifact@0 |
| 149 | displayName: 'Download win-arm64 Pipeline Artifact' |
| 150 | inputs: |
| 151 | artifactName: 'onnxruntime-extensions-win-arm64' |
| 152 | targetPath: '$(Build.BinariesDirectory)/artifact-downloads' |
| 153 | |
| 154 | - task: DownloadPipelineArtifact@0 |
| 155 | displayName: 'Download osx-all Pipeline Artifact' |
| 156 | inputs: |
| 157 | artifactName: 'onnxruntime-extensions-osx' |
| 158 | targetPath: '$(Build.BinariesDirectory)/artifact-downloads' |
| 159 | |
| 160 | - task: DownloadPipelineArtifact@2 |
| 161 | displayName: 'Download iOS Pipeline Artifact' |
| 162 | inputs: |
| 163 | artifactName: 'onnxruntime-extensions-ios_package' |
| 164 | targetPath: '$(Build.BinariesDirectory)/artifact-downloads' |
| 165 | |
| 166 | - task: DownloadPipelineArtifact@2 |
| 167 | displayName: 'Download android-full-aar Pipeline Artifact' |
| 168 | inputs: |
| 169 | artifactName: 'onnxruntime-extensions-android-aar' |
| 170 | patterns: '**/*.aar' |
| 171 | targetPath: '$(Build.BinariesDirectory)/artifact-downloads' |
| 172 | |
| 173 | - task: DownloadPipelineArtifact@0 |
| 174 | displayName: 'Download linux-x64 Pipeline Artifact' |
| 175 | inputs: |
| 176 | artifactName: 'onnxruntime-extensions-linux-x64' |
| 177 | targetPath: '$(Build.BinariesDirectory)/artifact-downloads' |
| 178 | |
| 179 | - task: DownloadPipelineArtifact@0 |
| 180 | displayName: 'Download linux-aarch64 Pipeline Artifact' |
| 181 | inputs: |
| 182 | artifactName: 'onnxruntime-extensions-linux-aarch64' |
| 183 | targetPath: '$(Build.BinariesDirectory)/artifact-downloads' |
| 184 | |
| 185 | - script: | |
| 186 | dir |
| 187 | workingDirectory: '$(Build.BinariesDirectory)/artifact-downloads' |
| 188 | displayName: 'List artifacts' |
| 189 | |
| 190 | # Reconstruct the build dir |
| 191 | - task: PowerShell@2 |
| 192 | displayName: 'Extract native libraries to artifact-downloads for addition to nuget native package' |
| 193 | inputs: |
| 194 | targetType: filePath |
| 195 | filePath: $(Build.SourcesDirectory)\tools\ci_build\extract_nuget_files.ps1 |
| 196 | arguments: $(Build.BinariesDirectory)/artifact-downloads $(Build.BinariesDirectory)\nuget-artifacts |
| 197 | |
| 198 | - task: NuGetToolInstaller@0 |
| 199 | displayName: Use Nuget 6.2.1 |
| 200 | inputs: |
| 201 | versionSpec: 6.2.1 |
| 202 | |
| 203 | - ${{ if eq(parameters.IsDummyPackage, false) }}: |
| 204 | - task: PowerShell@2 |
| 205 | displayName: 'Updating NativeNuget.NuSpec' |
| 206 | inputs: |
| 207 | targetType: 'inline' |
| 208 | script: | |
| 209 | $OrtExtVersion=(cat ./version.txt) |
| 210 | python $(Build.SourcesDirectory)\tools\ci_build\update_nuspec_for_native_nuget.py ` |
| 211 | --package_version $OrtExtVersion ` |
| 212 | --commit_id $(Build.SourceVersion) ` |
| 213 | --is_release_build ${{ parameters.IsReleaseBuild }} ` |
| 214 | --nuget_version_suffix ${{ parameters.NugetVersionSuffix }} |
| 215 | |
| 216 | cat $(Build.SourcesDirectory)\nuget\NativeNuget.nuspec |
| 217 | workingDirectory: '$(Build.SourcesDirectory)' |
| 218 | |
| 219 | - ${{ else }}: |
| 220 | - task: PowerShell@2 |
| 221 | displayName: 'Updating DummyNativeNuget.NuSpec, and props and targets filenames' |
| 222 | inputs: |
| 223 | targetType: 'inline' |
| 224 | script: | |
| 225 | $OrtExtVersion=(cat ./version.txt) |
| 226 | python $(Build.SourcesDirectory)\tools\ci_build\update_nuspec_for_native_nuget.py ` |
| 227 | --package_version $OrtExtVersion ` |
| 228 | --commit_id $(Build.SourceVersion) ` |
| 229 | --is_release_build ${{ parameters.IsReleaseBuild }} ` |
| 230 | --nuget_version_suffix ${{ parameters.NugetVersionSuffix }} ` |
| 231 | --nuspec_path $(Build.SourcesDirectory)\nuget\DummyNativeNuget.nuspec |
| 232 | |
| 233 | gci $(Build.SourcesDirectory)/nuget -Filter *.props -Recurse | Rename-Item -NewName { $_.name -replace 'Extensions', 'Extensions.Dummy' } |
| 234 | gci $(Build.SourcesDirectory)/nuget -Filter *.targets -Recurse | Rename-Item -NewName { $_.name -replace 'Extensions', 'Extensions.Dummy' } |
| 235 | |
| 236 | cat $(Build.SourcesDirectory)\nuget\DummyNativeNuget.nuspec |
| 237 | workingDirectory: '$(Build.SourcesDirectory)' |
| 238 | |
| 239 | - task: PowerShell@2 |
| 240 | displayName: 'Setup for packing' |
| 241 | inputs: |
| 242 | # copy nuget folder to binaries dir so we can refer to the assembled artifacts in |
| 243 | # $(Build.BinariesDirectory)/nuget-artifacts using a deterministic relative path in the nuspec. |
| 244 | targetType: 'inline' |
| 245 | script: | |
| 246 | cp -r $(Build.SourcesDirectory)/nuget $(Build.BinariesDirectory) |
| 247 | cp $(Build.SourcesDirectory)/ThirdPartyNotices.txt $(Build.BinariesDirectory) |
| 248 | |
| 249 | workingDirectory: '$(Build.SourcesDirectory)' |
| 250 | |
| 251 | - ${{ if eq(parameters.IsDummyPackage, false) }}: |
| 252 | - task: NuGetCommand@2 |
| 253 | displayName: Packing Microsoft.ML.OnnxRuntime.Extensions NuGet-package |
| 254 | inputs: |
| 255 | command: 'pack' |
| 256 | packagesToPack: '$(Build.BinariesDirectory)\nuget\NativeNuget.nuspec' |
| 257 | packDestination: $(Build.ArtifactStagingDirectory) |
| 258 | |
| 259 | - ${{ else }}: |
| 260 | - task: NuGetCommand@2 |
| 261 | displayName: Packing Microsoft.ML.OnnxRuntime.Extensions.Dummy NuGet-package |
| 262 | inputs: |
| 263 | command: 'pack' |
| 264 | packagesToPack: '$(Build.BinariesDirectory)\nuget\DummyNativeNuget.nuspec' |
| 265 | packDestination: $(Build.ArtifactStagingDirectory) |
| 266 | |
| 267 | - template: esrp_nuget.yml |
| 268 | parameters: |
| 269 | DisplayName: 'ESRP - sign NuGet package' |
| 270 | FolderPath: '$(Build.ArtifactStagingDirectory)' |
| 271 | DoEsrp: 'true' |
| 272 | |
| 273 | - task: PublishPipelineArtifact@1 |
| 274 | inputs: |
| 275 | targetPath: '$(Build.ArtifactStagingDirectory)' |
| 276 | artifactName: 'drop-signed-nuget-CPU' |
| 277 | |
| 278 | - task: mspremier.PostBuildCleanup.PostBuildCleanup-task.PostBuildCleanup@3 |
| 279 | displayName: 'Clean Agent Directories' |
| 280 | condition: always() |
| 281 | |