For now, this script is based on SVN conventions
The primary purpose of this script, besides automating deployment is:
- Automated tagging of releases
- Deployment of tests to testing servers (for A/B testing)
- Deployment of latest release to staging environment
- Notification with commit comments, diffs, etc. for each new release
I've recently began setting up automated deployment for my various PHP apps to testing, staging & development servers. Namely, sites such as WhiteFence.com, ElectricityTexas.com and several other client sites.
I'm moving all of my projects to Git, so this script will be modified accordingly.
There are 3 files involved with deployment:
-
deploy
Defines the repositores, servers, and notification email, as well as how logging is handled.
-
deployment.py
Class that actually performs the deployment. This is highly based on convention.
-
capistrano.sh
An
expect
script that performed many of the SVN operations. This is because various SVN commands sent false EOF signals to Python (most likely because of child processes spawning) and had to be caught viaexpect
.
Many of the commands from the script are based on folder structure, which should be as follows:
my-project/
trunk/
branches/
tags/
tests/
*todo*
# deploy my-project
# deploy --stage my-project
# deploy --tests my-project
# deploy --tests --stage my-project
- Script checks latest revision of
my-project
,trunk
, and latesttag
. - If the
trunk
has been modified since lasttag
, a newtag
is made at that revision. - Script decides testing tier based on the presence of
--stage
switch. - Capistrano script is created for deploying the latest
tag
to the proper tier. - Capistrano script is ran:
- Remote deployment folder is initialized.
- Old releases are cleaned up.
- New release is exported to
/releases
& symlinked to/current
folder on tier.
- If there is an error, Capistrano performs a
--rollback
. - Finished.
The process is the same as above, except that:
- Tests in the
/tests
folder are not tagged, and are simply deployed as-is. - Tests are spread across the testing tier. For example, if there are 2 tests and 4 servers,
Test A
will be placed on servers 1 & 2, whileTest B
will be placed on servers 3 & 4.