How to upload an app to TestFairy via API

There are two ways to upload apps to TestFairy: The easy way and the smart way.
The easy way is to use the web upload. As simple as it sounds, just click on the upload button and your’re done.
The smart way is to use our command line uploader.
Why is it better? Because when you upload your app via the web interface, after adding our magic we sign it with our certificate instead of yours. It works perfectly for the majority of apps, however if your app uses 3rd party APIs such as Google In App Billing, Google Maps, Facebook connect and such, those services may not like our signature. For those services where your signature is required, our command line uploader will upload your app, wait for it to be instrumented, get it back, sign it with your signature, and re-upload it to our server. If you are using Jenkins or any other continuous integration platform, this script can be a perfect match.
The code is on our GitHub, please free to change it and offer improvements if you can think of anything useful.