Saturday, April 12, 2008

Download Your Code from Google App Engine

I've been toying around with Google App Engine a little. One feature (among several) that is missing right now is the ability to download your source code after deploying it. (Sure, sure, ..., you should really have your code in a source control system.) While it is likely that Google will give us the ability to download our code in the coming days, I've written a small Makefile that you can use to create a source archive of your site. By deploying the source archive along with your site and then password protecting it you will always have the source handy. Here is the Makefile:



If you put this in the root of your application and run "make", an archive of the entire application will be stored in archive/archive.tgz. Now you probably want to password protect this resource so add the following in your app.yaml file:



Now if you go to http://yourapp.appspot.com/archive/archive.tgz you'll be prompted to login to download the source archive.

Don't ask me how long it took me to figure out I needed to use two dollar signs on the fancy parameter substitution $${PWD##*/} because it is a shell variable and not a make variable -- really, don't ask.

4 comments:

  1. Excellent idea! Used it as soon as I found it. Because I don't like Makefiles however, and I'm also on a Mac (which means that tar includes ._ files when creating the archive), I created a shell script that does the same job, using pretty much all of the code you posted here and a bit more :)

    Thanks!

    ReplyDelete
  2. Do you have any mercy on windows (DOS) users ?

    ReplyDelete
  3. @Common Man - no, I greatly disdain them and have no mercy on their souls.

    Just kidding.

    You could probably write a batch file for this if you are good with dos batch files - not my thing.

    ReplyDelete