[iOS] Packaging pipeline improvements. (#8324)

Updates to the iOS packaging pipeline:
- Make it harder to overwrite package archives accidentally when uploading (fails if the archive already exists)
- Only upload package archives for release builds
- Some clean up
This commit is contained in:
Edward Chen 2021-07-13 18:48:28 -07:00 committed by GitHub
parent 0020703d00
commit 16f6904232
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 21 deletions

View file

@ -6,7 +6,7 @@
set -e
set -x
USAGE_TEXT="Usage: ${0} <binaries staging directory> <artifacts staging directory> <ORT pod version>"
USAGE_TEXT="Usage: ${0} <binaries staging directory> <artifacts staging directory> <ORT pod version> <whether to upload the package archives, 'true' or 'false'>"
abspath() {
local INPUT_PATH=${1:?"Expected path as the first argument."}
@ -18,6 +18,7 @@ BINARIES_STAGING_DIR=$(abspath "${1:?${USAGE_TEXT}}")
# staging directory for build artifacts (destination)
ARTIFACTS_STAGING_DIR=$(abspath "${2:?${USAGE_TEXT}}")
ORT_POD_VERSION=${3:?${USAGE_TEXT}}
SHOULD_UPLOAD_ARCHIVES=${4:?${USAGE_TEXT}}
STORAGE_ACCOUNT_NAME="onnxruntimepackages"
STORAGE_ACCOUNT_CONTAINER_NAME="ortmobilestore"
@ -34,13 +35,16 @@ assemble_and_upload_pod() {
zip -r ${ARTIFACTS_STAGING_DIR}/${POD_ARCHIVE_BASENAME} * --exclude ${PODSPEC_BASENAME}
cp ${PODSPEC_BASENAME} ${ARTIFACTS_STAGING_DIR}/${PODSPEC_BASENAME}
# upload the pod archive and set the podspec source to the pod archive URL
az storage blob upload \
--account-name ${STORAGE_ACCOUNT_NAME} --container-name ${STORAGE_ACCOUNT_CONTAINER_NAME} \
--file ${ARTIFACTS_STAGING_DIR}/${POD_ARCHIVE_BASENAME} --name ${POD_ARCHIVE_BASENAME}
if [[ "${SHOULD_UPLOAD_ARCHIVES}" == "true" ]]; then
# upload the pod archive and set the podspec source to the pod archive URL
az storage blob upload \
--account-name ${STORAGE_ACCOUNT_NAME} --container-name ${STORAGE_ACCOUNT_CONTAINER_NAME} \
--file ${ARTIFACTS_STAGING_DIR}/${POD_ARCHIVE_BASENAME} --name ${POD_ARCHIVE_BASENAME} \
--if-none-match "*"
sed -i "" -e "s|file:///http_source_placeholder|${STORAGE_URL_PREFIX}/${POD_ARCHIVE_BASENAME}|" \
${ARTIFACTS_STAGING_DIR}/${PODSPEC_BASENAME}
sed -i "" -e "s|file:///http_source_placeholder|${STORAGE_URL_PREFIX}/${POD_ARCHIVE_BASENAME}|" \
${ARTIFACTS_STAGING_DIR}/${PODSPEC_BASENAME}
fi
popd
}

View file

@ -32,13 +32,20 @@ jobs:
VERSION="${BASE_VERSION}-dev"
fi
echo "##vso[task.setvariable variable=ORT_POD_VERSION]${VERSION}"
echo "Version number: ${VERSION}"
displayName: "Set version number"
set_var() {
local VAR_NAME=${1:?}
local VAR_VALUE=${2:?}
echo "##vso[task.setvariable variable=${VAR_NAME}]${VAR_VALUE}"
echo "${VAR_NAME}: ${VAR_VALUE}"
}
set_var "ORT_POD_VERSION" "${VERSION}"
set_var "ORT_SHOULD_UPLOAD_ARCHIVES" "${IS_RELEASE_BUILD}"
displayName: "Set variables"
- script: |
python tools/ci_build/github/apple/build_ios_framework.py \
--build_dir $(Build.BinariesDirectory)/ios_framework \
--build_dir "$(Build.BinariesDirectory)/ios_framework" \
--include_ops_by_config tools/ci_build/github/android/mobile_package.required_operators.config \
tools/ci_build/github/apple/default_mobile_ios_framework_build_settings.json
displayName: "Build iOS framework"
@ -46,15 +53,15 @@ jobs:
- script: |
python tools/ci_build/github/apple/test_ios_packages.py \
--fail_if_cocoapods_missing \
--c_framework_dir $(Build.BinariesDirectory)/ios_framework/framework_out
--c_framework_dir "$(Build.BinariesDirectory)/ios_framework/framework_out"
displayName: "Test iOS framework"
- script: |
python tools/ci_build/github/apple/c/assemble_c_pod_package.py \
--staging-dir $(Build.BinariesDirectory)/staging/onnxruntime-mobile-c \
--staging-dir "$(Build.BinariesDirectory)/staging/onnxruntime-mobile-c" \
--pod-version ${ORT_POD_VERSION} \
--framework-info-file $(Build.BinariesDirectory)/ios_framework/framework_info.json \
--framework-dir $(Build.BinariesDirectory)/ios_framework/framework_out/onnxruntime.framework
--framework-info-file "$(Build.BinariesDirectory)/ios_framework/framework_info.json" \
--framework-dir "$(Build.BinariesDirectory)/ios_framework/framework_out/onnxruntime.framework"
displayName: "Assemble onnxruntime-mobile-c pod files"
- script: |
@ -64,14 +71,14 @@ jobs:
- script: |
python tools/ci_build/github/apple/objectivec/assemble_objc_pod_package.py \
--staging-dir $(Build.BinariesDirectory)/staging/onnxruntime-mobile-objc \
--staging-dir "$(Build.BinariesDirectory)/staging/onnxruntime-mobile-objc" \
--pod-version ${ORT_POD_VERSION} \
--framework-info-file $(Build.BinariesDirectory)/ios_framework/framework_info.json
--framework-info-file "$(Build.BinariesDirectory)/ios_framework/framework_info.json"
displayName: "Assemble onnxruntime-mobile-objc pod files"
- script: |
pod lib lint --verbose \
--include-podspecs=$(Build.BinariesDirectory)/staging/onnxruntime-mobile-c/onnxruntime-mobile-c.podspec
--include-podspecs="$(Build.BinariesDirectory)/staging/onnxruntime-mobile-c/onnxruntime-mobile-c.podspec"
workingDirectory: "$(Build.BinariesDirectory)/staging/onnxruntime-mobile-objc"
displayName: "Check onnxruntime-mobile-objc pod"
@ -79,7 +86,7 @@ jobs:
set -e
gem install jazzy
jazzy --config objectivec/docs/jazzy_config.yaml \
--output $(Build.BinariesDirectory)/staging/objc_api_docs \
--output "$(Build.BinariesDirectory)/staging/objc_api_docs" \
--module-version ${ORT_POD_VERSION}
displayName: "Generate Objective-C API docs"
@ -89,9 +96,13 @@ jobs:
scriptType: 'bash'
scriptLocation: 'scriptPath'
scriptPath: 'tools/ci_build/github/apple/assemble_ios_packaging_artifacts.sh'
arguments: '"$(Build.BinariesDirectory)/staging" "$(Build.ArtifactStagingDirectory)" "$(ORT_POD_VERSION)"'
arguments: >-
"$(Build.BinariesDirectory)/staging"
"$(Build.ArtifactStagingDirectory)"
"$(ORT_POD_VERSION)"
"$(ORT_SHOULD_UPLOAD_ARCHIVES)"
displayName: "Assemble artifacts"
- publish: $(Build.ArtifactStagingDirectory)
- publish: "$(Build.ArtifactStagingDirectory)"
artifact: ios_packaging_artifacts
displayName: "Publish artifacts"