Xcode Cloud
You can use the Fastlane action or HTTP API to upload builds as part of an Xcode Cloud workflow.
Xcode Cloud is a continuous integration system built by Apple, focusing on ease of use and direct integration into the Xcode environment. Whether you are using Fastlane or prefer to use Emerge's REST API it's easy to integrate a build upload step into your Xcode Cloud environment. This method is a great way to get started with Emerge if your project hasn't yet set up Github Actions.
Here is an example of a script you can use to upload. This file would be in ci_scripts/ci_post_xcodebuild.sh
In this example the repo_name variable needs to be replaced with the name of your repo.
#!/bin/sh
set -e
if [[ -z "${CI_ARCHIVE_PATH}" ]]; then
echo "No CI_ARCHIVE_PATH set, skipping Emerge upload"
else
required_env_vars=(
"CI_ARCHIVE_PATH"
"EMERGE_API_KEY"
"CI_BRANCH"
"CI_COMMIT"
)
for var in "${required_env_vars[@]}"; do
if [[ -z "${!var}" ]]; then
echo "Environment variable $var is not set"
exit 1
fi
done
brew install jq
zip_path="$CI_ARCHIVE_PATH.zip"
pushd $(dirname $CI_ARCHIVE_PATH)
zip -r "$(basename $zip_path)" "$(basename $CI_ARCHIVE_PATH)"
popd
# Update this with your repo
repo_name='MyOrg/MyRepo'
if [[ "$CI_XCODE_SCHEME" == "My Debug Archive Scheme" ]]; then
tag='debug'
else
tag='release'
fi
json_fields=$(cat <<EOF
"filename":"${zip_path}",
"branch":"${CI_BRANCH}",
"sha":"${CI_COMMIT}",
"repoName":"${repo_name}",
"tag":"${tag}"
EOF
)
if [[ -z "${CI_PULL_REQUEST_NUMBER}" ]]; then
echo "Not a pull request, omitting pull request JSON fields"
else
required_env_vars=(
"CI_PULL_REQUEST_NUMBER"
"CI_PULL_REQUEST_TARGET_COMMIT"
)
for var in "${required_env_vars[@]}"; do
if [[ -z "${!var}" ]]; then
echo "Environment variable $var is not set"
exit 1
fi
done
json_fields=$(cat <<EOF
${json_fields},
"prNumber":"${CI_PULL_REQUEST_NUMBER}",
"baseSha":"${CI_PULL_REQUEST_TARGET_COMMIT}"
EOF
)
fi
upload_response=$(curl \
--url "https://api.emergetools.com/upload" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header "X-API-Token: $EMERGE_API_KEY" \
--data "{$json_fields}")
# Pull the uploadURL field from the response using jq
upload_url=$(echo "$upload_response" | jq -r .uploadURL)
curl -v -H 'Content-Type: application/zip' -T "$zip_path" "$upload_url"
fi
Updated about 2 months ago