Skip to content

Instantly share code, notes, and snippets.

@mataneine
Forked from jedi4ever/upload-to-appstore.sh
Last active February 10, 2016 15:31
Show Gist options
  • Save mataneine/4079eee8c401a082c400 to your computer and use it in GitHub Desktop.
Save mataneine/4079eee8c401a082c400 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# This scripts allows you to upload a binary to the iTunes Connect Store and do it for a specific apple-id
# Because when you have multiple apps in status for download, xcodebuild upload will complain that multiple apps are in wait status
#
# Requires application loader to be installed
# See https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/SubmittingTheApp.html
usage()
{
cat << EOF
usage: $0 -u <arg> [-p <arg>] -f <arg> -s <arg> [-l <arg>]
-h Show this help.
-u <arg> The -u option specifies your username.
-p <arg> The -p option specifies your password.
-f <arg> The -f option specifies a filename for a single package you want
to upload.
-v <arg> The -v option value specifies the vendor identifier used
when generating the metadata XML for the content known by Apple.
You cannot use this option with -apple_id option.
-l <arg> The -l option specifies the level of logging. The five values
are: off, detailed, informational, critical, eXtreme.
EOF
}
iTMSTransporter=/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/MacOS/itms/bin/iTMSTransporter
USERNAME=
PASSWORD=
IPA=
VENDOR_ID=
LOGLEVEL=off
while getopts "hu:p:f:v:l:" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
u)
USERNAME=$OPTARG
;;
p)
PASSWORD=$OPTARG
;;
f)
IPA=$OPTARG
;;
v)
VENDOR_ID=$OPTARG
;;
l)
LOGLEVEL=$OPTARG
;;
?)
usage
exit
;;
esac
done
if [[ -z $USERNAME ]] || [[ -z $PASSWORD ]] || [[ -z $IPA ]] || [[ -z $VENDOR_ID ]]
then
usage
exit 1
fi
APPLE_ID=`"${iTMSTransporter}" -u $USERNAME -p $PASSWORD -v $LOGLEVEL -m lookupMetadata -vendor_id $VENDOR_ID -destination /tmp/ >/dev/null 2>&1 && cat /tmp/$VENDOR_ID.itmsp/metadata.xml | grep apple-id | cut -d ">" -f2 | cut -d "<" -f1`
IPA_FILENAME=$(basename $IPA)
BUNDLE_FILENAME=$(basename $IPA .ipa)
MD5=$(md5 -q $IPA)
BYTESIZE=$(stat -f "%z" $IPA)
ITMSP=$BUNDLE_FILENAME.itmsp
test -d $ITMSP && rm -rf $ITMSP && mkdir $ITMSP
cp $IPA $ITMSP
# You can see this debug info when you manually do an app upload with the Application Loader
# It's when you click activity
cat <<EOM > ${ITMSP}/metadata.xml
<?xml version="1.0" encoding="UTF-8"?>
<package version="software4.7" xmlns="http://apple.com/itunes/importer">
<software_assets apple_id="$APPLE_ID">
<asset type="bundle">
<data_file>
<file_name>$IPA_FILENAME</file_name>
<checksum type="md5">$MD5</checksum>
<size>$BYTESIZE</size>
</data_file>
</asset>
</software_assets>
</package>
EOM
"${iTMSTransporter}" -m upload -f $ITMSP -u $USERNAME -p $PASSWORD -v $LOGLEVEL -throughput
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment