Skip to content

Instantly share code, notes, and snippets.

@tpryan
Created November 22, 2011 22:06
Show Gist options
  • Save tpryan/1387176 to your computer and use it in GitHub Desktop.
Save tpryan/1387176 to your computer and use it in GitHub Desktop.
#! /bin/sh
project="[phonegap projectnumber]";
username="[phonegap username]";
password="[phonegap password]";
appPath="[path to www folder];
projectPath="[path where you want the apk file];
##commit changes
echo "Forcing changes to github";
cd $appPath
null=$(git commit -m "auto commit as part of script");
null=$(git push origin master);
echo "Done";
cd $projectPath
##Request Phonegap data
echo "Requesting Project Data.";
package=$(curl -s -u $username:$password https://build.phonegap.com/api/v1/apps/$project | grep -Po '"package":.*?[^\\],');
title=$(curl -s -u $username:$password https://build.phonegap.com/api/v1/apps/$project | grep -Po '"title":.*?[^\\],');
title=${title##*:};
title=$(echo $title|sed 's/,//g');
title=$(echo $title|sed 's/"//g');
package=${package##*:};
package=$(echo $package|sed 's/,//g');
package=$(echo $package|sed 's/"//g');
echo "Done. ";
##Request Rebuild
echo "Requesting Rebuild.";
request=$(curl -s -u $username:$password -X PUT -d 'data={"pull":"true"}' https://build.phonegap.com/api/v1/apps/$project);
echo "Done. ";
donecheck="";
echo "\nWaiting for rebuild to be done.";
while [$donecheck -eq ""]
do
echo ".";
sleep 10;
donecheck=$(curl -s -u $username:$password https://build.phonegap.com/api/v1/apps/$project | grep -Po '"android":"complete"');
done
echo "Done. Now downloading.\n";
##Download File
download=$(curl -L -s -u $username:$password -o $title-debug.apk https://build.phonegap.com/apps/$project/download/android);
##Install on Device
~/Downloads/android-sdk/platform-tools/adb uninstall $package
~/Downloads/android-sdk/platform-tools/adb install -r ./$title-debug.apk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment