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