Last active
August 29, 2015 13:56
-
-
Save nikolaykasyanov/9325309 to your computer and use it in GitHub Desktop.
Script for updating Apple provisioning profiles. Can be used on CI servers like Jenkins.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
function fetchProvisioningProfiles() | |
{ | |
ios profiles:download:all --type development | |
DEVELOPMENT_RESULT=$? | |
if [ "$DEVELOPMENT_RESULT" -ne "0" ]; then | |
return 1 | |
fi | |
ios profiles:download:all --type distribution | |
DISTRIBUTION_RESULT=$? | |
if [ "$DEVELOPMENT_RESULT" -ne "0" ]; then | |
return 1 | |
fi | |
return 0 | |
} | |
DOWNLOAD_PATH=/tmp/$(date | md5) | |
PROVISIONING_PATH="$HOME/Library/MobileDevice/Provisioning Profiles" | |
mkdir "$DOWNLOAD_PATH" | |
cd "$DOWNLOAD_PATH" | |
if fetchProvisioningProfiles; then | |
rm -rf "$PROVISIONING_PATH/*" | |
if [ "$?" -ne "0" ]; then | |
echo "Cannot remove existing provisioning profiles" | |
exit 1 | |
fi | |
find "$DOWNLOAD_PATH" -name '*.mobileprovision' | xargs -I '{}' mv '{}' "$PROVISIONING_PATH/" | |
rm -rf "$DOWNLOAD_PATH" | |
if [ "$?" -ne "0" ]; then | |
echo "Cannot remove temporary download folder" | |
exit 1 | |
fi | |
echo "Successfuly updated provisioning profiles" | |
else | |
echo "Couldn't download provisioning profiles from Apple Developer Center, using existing ones" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ x"$1" == x"" ]; then | |
echo "Developer account name (email) not specified" | |
exit 1 | |
fi | |
if [ x"$2" == x"" ]; then | |
echo "Developer account password not specified" | |
exit 1 | |
fi | |
if [ x"$3" == x"" ]; then | |
echo "Profile name not specified" | |
exit 1 | |
fi | |
if [ x"$4" == x"" ]; then | |
echo "Profile type not specified" | |
exit 1 | |
fi | |
DOWNLOAD_PATH=/tmp/$(date | md5) | |
PROVISIONING_PATH="$HOME/Library/MobileDevice/Provisioning Profiles" | |
mkdir "$DOWNLOAD_PATH" | |
cd "$DOWNLOAD_PATH" | |
ios profiles:download "$3" --type $4 --username "$1" --password "$2" | |
if [ "$?" -ne "0" ]; then | |
echo "Error while downloading $4 profile '$3'" | |
exit 1 | |
else | |
find "$DOWNLOAD_PATH" -name '*.mobileprovision' | xargs -I '{}' mv '{}' "$PROVISIONING_PATH/" | |
rm -rf "$DOWNLOAD_PATH" | |
echo "Successfuly updated $4 profile '$3'" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment