microsoft/onnxruntime-extensions
Publicmirrored fromhttps://github.com/microsoft/onnxruntime-extensionsAvailable
.pipelines/templates/build-package-for-ios-cocoapods.yml
146lines · modecode
| 1 | # packaging pipeline for iOS CocoaPods package |
| 2 | |
| 3 | parameters: |
| 4 | - name: IsReleaseBuild |
| 5 | displayName: "Is this a release build?" |
| 6 | type: boolean |
| 7 | default: false |
| 8 | |
| 9 | |
| 10 | - name: AdditionalBuildFlags |
| 11 | displayName: Additional build flags for /tools/ios/build_xcframework.py |
| 12 | type: string |
| 13 | |
| 14 | jobs: |
| 15 | - template: ios-framework-build.yml |
| 16 | parameters: |
| 17 | Platform: 'iphoneos' |
| 18 | IosArch: 'arm64' |
| 19 | IsReleaseBuild: ${{parameters.IsReleaseBuild}} |
| 20 | AdditionalBuildFlags: ${{parameters.AdditionalBuildFlags}} |
| 21 | |
| 22 | - template: ios-framework-build.yml |
| 23 | parameters: |
| 24 | Platform: 'iphonesimulator' |
| 25 | IosArch: 'x86_64' |
| 26 | IsReleaseBuild: ${{parameters.IsReleaseBuild}} |
| 27 | AdditionalBuildFlags: ${{parameters.AdditionalBuildFlags}} |
| 28 | |
| 29 | - template: ios-framework-build.yml |
| 30 | parameters: |
| 31 | Platform: 'iphonesimulator' |
| 32 | IosArch: 'arm64' |
| 33 | IsReleaseBuild: ${{parameters.IsReleaseBuild}} |
| 34 | AdditionalBuildFlags: ${{parameters.AdditionalBuildFlags}} |
| 35 | |
| 36 | - job: IosPackaging |
| 37 | condition: not(or(failed(), canceled())) |
| 38 | displayName: "iOS Packaging" |
| 39 | dependsOn: |
| 40 | - IOS_C_API_Packaging_iphoneos_arm64 |
| 41 | - IOS_C_API_Packaging_iphonesimulator_arm64 |
| 42 | - IOS_C_API_Packaging_iphonesimulator_x86_64 |
| 43 | pool: |
| 44 | vmImage: "macOS-12" |
| 45 | |
| 46 | timeoutInMinutes: 120 |
| 47 | |
| 48 | steps: |
| 49 | - checkout: self |
| 50 | submodules: true |
| 51 | - task: UsePythonVersion@0 |
| 52 | inputs: |
| 53 | versionSpec: "3.9" |
| 54 | addToPath: true |
| 55 | architecture: "x64" |
| 56 | |
| 57 | # iOS xcframework build doesn't work with CMake 3.25.1, pin to 3.25.0 |
| 58 | - script: | |
| 59 | python -m pip install cmake==3.25.0 |
| 60 | displayName: "Install CMake 3.25.0" |
| 61 | |
| 62 | - template: set-package-version-variable-step.yml |
| 63 | parameters: |
| 64 | IsReleaseBuild: ${{ parameters.IsReleaseBuild }} |
| 65 | PackageVersionVariableName: ORT_EXTENSIONS_POD_VERSION |
| 66 | |
| 67 | - task: DownloadPipelineArtifact@2 |
| 68 | inputs: |
| 69 | artifact: 'onnxruntime-extensions-ios-iphoneos-arm64-lib' |
| 70 | targetPath: '$(Build.BinariesDirectory)/' |
| 71 | |
| 72 | - task: DownloadPipelineArtifact@2 |
| 73 | inputs: |
| 74 | artifact: 'onnxruntime-extensions-ios-iphonesimulator-arm64-lib' |
| 75 | targetPath: '$(Build.BinariesDirectory)/' |
| 76 | |
| 77 | - task: DownloadPipelineArtifact@2 |
| 78 | inputs: |
| 79 | artifact: 'onnxruntime-extensions-ios-iphonesimulator-x86_64-lib' |
| 80 | targetPath: '$(Build.BinariesDirectory)/' |
| 81 | |
| 82 | - script: | |
| 83 | set -e -x |
| 84 | ls |
| 85 | if ! ls onnxruntime-extensions-ios*.tgz &> /dev/null; then |
| 86 | echo "no tgz files found. It's not distributed building, skip!" |
| 87 | exit 0 |
| 88 | fi |
| 89 | for tgz_lib in `ls onnxruntime-extensions-ios*.tgz` |
| 90 | do |
| 91 | echo "decompress $tgz_lib" |
| 92 | tar -xvzf $tgz_lib |
| 93 | done |
| 94 | |
| 95 | ls |
| 96 | ls xcframework_out/intermediates/* |
| 97 | workingDirectory: $(Build.BinariesDirectory) |
| 98 | displayName: "Extract file from distributed build" |
| 99 | |
| 100 | - script: | |
| 101 | python ./tools/ios/build_xcframework.py \ |
| 102 | --output_dir $(Build.BinariesDirectory)/xcframework_out \ |
| 103 | --config Release \ |
| 104 | --mode pack_xcframework_only |
| 105 | displayName: "Pack xcframework for distributed building" |
| 106 | |
| 107 | - script: | |
| 108 | python ./tools/ios/assemble_pod_package.py \ |
| 109 | --staging-dir $(Build.BinariesDirectory)/pod_staging \ |
| 110 | --xcframework-output-dir $(Build.BinariesDirectory)/xcframework_out \ |
| 111 | --pod-version ${ORT_EXTENSIONS_POD_VERSION} |
| 112 | displayName: "Assemble pod" |
| 113 | |
| 114 | - script: | |
| 115 | ls -lR $(Build.BinariesDirectory)/pod_staging |
| 116 | pod lib lint |
| 117 | displayName: "Lint pod" |
| 118 | workingDirectory: $(Build.BinariesDirectory)/pod_staging |
| 119 | |
| 120 | - script: | |
| 121 | ORT_EXTENSIONS_LOCAL_POD_PATH=$(Build.BinariesDirectory)/pod_staging \ |
| 122 | pod install |
| 123 | displayName: "Install pods for OrtExtensionsUsage" |
| 124 | workingDirectory: $(Build.SourcesDirectory)/test/ios/OrtExtensionsUsage |
| 125 | |
| 126 | - script: | |
| 127 | set -e -x |
| 128 | |
| 129 | POD_STAGING_DIR="$(Build.BinariesDirectory)/pod_staging" |
| 130 | ARTIFACTS_STAGING_DIR="$(Build.ArtifactStagingDirectory)" |
| 131 | POD_NAME="onnxruntime-extensions-c" |
| 132 | POD_ARCHIVE_BASENAME="pod-archive-${POD_NAME}-${ORT_EXTENSIONS_POD_VERSION}.zip" |
| 133 | PODSPEC_BASENAME="${POD_NAME}.podspec" |
| 134 | |
| 135 | pushd ${POD_STAGING_DIR} |
| 136 | |
| 137 | # assemble the files in the artifacts staging directory |
| 138 | zip -r ${ARTIFACTS_STAGING_DIR}/${POD_ARCHIVE_BASENAME} * --exclude ${PODSPEC_BASENAME} |
| 139 | cp ${PODSPEC_BASENAME} ${ARTIFACTS_STAGING_DIR}/${PODSPEC_BASENAME} |
| 140 | |
| 141 | popd |
| 142 | displayName: "Assemble artifacts" |
| 143 | |
| 144 | - publish: "$(Build.ArtifactStagingDirectory)" |
| 145 | artifact: onnxruntime-extensions-ios_package |
| 146 | displayName: "Publish artifacts" |