Wednesday, July 6, 2011

My Deploy Script

Being a development shop often of just 1, I found myself going through many of the same steps to deploy my site to production. Every time I would send it to production, I would think "This should be automated". Over time, I automated a couple step, with human interaction at steps that would require checking for failure, or certain things that would not be easily automated. The more I worked with the deploy script the more I refined the process until now I have a script that allows me to double-click, enter a comment for the subversion update, and then everything else, including error checking, is automated.





This process goes through all the following steps:
  1. Subversion Checkin / Checkout / Export
  2. ASP.NET 4 site precompile.
  3. If compile fails, abort script
  4. Map to netowork drive on production server.
  5. Zip compiled application with unique name onto production server.
  6. Copy a version to the network for archival purposes
  7. Notify the production server of new app.
  8. Production server unzips new app, deletes old, replaces old with new via file move (less than a second of "downtime")
  9. Send noficiation tweet to @cledwyn that the process has happened.

This requires having a "Scheduled Task" on the production server.


Tools that you will need to get this working.

  • Yes this is for a windows environment.  All scripts could be adapted for Mac/Linux....
  • Visual Studio 2010 is helpful
  • Tweepy:  A great python command line tool for posting to twitter.
  • Tortoise SVN.  Invaluable subversion tool.
  • 7za: Command Line version of 7Zip.