Created
September 11, 2015 16:36
-
-
Save kazukgw/0d0dba2ccabf386ef86a to your computer and use it in GitHub Desktop.
plist と ipa をつくってscp でuploadするやつ
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
_usage() { | |
cat << _USAGE_ | |
usage: upload_ipa <config_json> <version> | |
This program depends on the following commands | |
jq | |
ipa (shenzhen) | |
and needs config.json like this. | |
{ | |
"plist":"project/Info.plist", | |
"ipaurl":"https://path/to/project.ipa", | |
"title":"title_in_plist", | |
"bundle_id":"jp.co.foo.bar", | |
"scp": { | |
"dest": "host_name_or_ip:hostpath", // e.g. "168.33.192.12:~/ipas/" | |
"user": "username", | |
"identity_file": "/Users/myuser/.ssh/id_rsa" | |
} | |
} | |
_USAGE_ | |
} | |
_conf() { | |
echo $(jq "$1" $config_file | sed -e 's/[" ]//g') | |
} | |
_require() { | |
type $1 >/dev/null 2>&1 | |
echo $? | |
} | |
if [[ $# -ne 2 || $(_require "jq") -eq 1 || $(_require "ipa") -eq 1 ]] | |
then | |
_usage | |
exit | |
fi | |
if [[ ! -f $1 ]] | |
then | |
_usage | |
exit | |
fi | |
_xcodeprojfile=$(ls | grep xcodeproj) | |
name=${_xcodeprojfile%.*} | |
config_file=$1 | |
version=$2 | |
ipaurl=$(_conf ".ipaurl") | |
title=$(_conf ".title") | |
bundle_id=$(_conf ".bundle_id") | |
scp_dest=$(_conf ".scp.dest") | |
scp_user=$(_conf ".scp.user") | |
scp_identity_file=$(_conf ".scp.identity_file") | |
dest_dirname="${name}_${version}" | |
plist="${name}.plist" | |
ipa_file="${name}.ipa" | |
echo "===> generate plist file for download" | |
cat << EOF > $plist | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>items</key> | |
<array> | |
<dict> | |
<key>assets</key> | |
<array> | |
<dict> | |
<key>kind</key> | |
<string>software-package</string> | |
<key>url</key> | |
<string>$ipaurl</string> | |
</dict> | |
</array> | |
<key>metadata</key> | |
<dict> | |
<key>bundle-identifier</key> | |
<string>$bundle_id</string> | |
<key>kind</key> | |
<string>software</string> | |
<key>title</key> | |
<string>$title</string> | |
</dict> | |
</dict> | |
</array> | |
</dict> | |
</plist> | |
EOF | |
echo "===> create ipa file" | |
ipa build | |
rm ${name}.app.dSYM.zip | |
echo "===> create tmp dir and mv ipa & plist" | |
mkdir $dest_dirname | |
mv $ipa_file ${dest_dirname}/ | |
mv $plist ${dest_dirname}/ | |
echo "===> scp to remote host" | |
scp -r -i $scp_identity_file $dest_dirname $scp_user@$scp_dest | |
echo "===> rm tmp dir" | |
rm -r $dest_dirname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment