nadarei/mina — pull request #49 by MafcoCinco (2012-08-22 21:06:08+00:00)
Title: Release Sub-Directory Date Naming Scheme

Hello

I have made changes to allow the sub-directories under *releases/* to be named using the current date instead of a sequencing scheme. This helps synchronize deployment of multiple gems that are part of a larger system. For example, if you want the version of the system as it existed on August 12, 2012, you would point the symbolic link for each gem to *releases/20120812*. With a sequenced naming scheme, it is much more difficult to identify which deployments compose a working version of the system.

USAGE

In your project's *deploy.rb* file, add the following line

set :version_scheme, :date

Adding this setting will name sub-directories of *releases/* using a *YYYYMMDD* format. The behavior defaults to original sequenced version naming.

CHANGES

*lib/mina/deploy.rb*: changed the bash script to retrieve a directory listing using the directory creation date rather than the directory name. This allows the cleanup function to continue to work correctly independent of what the sub-directories in *releases/* are named

*data/deploy.sh.erb*: changed the version variable declaration to call a function in *lib/mina/deploy_helpers.rb* instead of calculating the version number locally in script. This abstraction allows the version to be something other than an integer which is incremented with each deploy

*lib/mina/deploy_helpers.rb*: added the version function which returns the current version. Sequenced naming is the default behavior. Date naming is enabled via the *:version_scheme* setting as described above

*lib/mina/version.rb*: Incremented the version number. Not sure what the policy is on this, but it made sense for local development and I figured I could leave it in for now.

OTHER NOTES

As it is currently implemented, the date naming scheme is most applicable to deployments that happen, at most, once per day. The time portion of the date is not currently included in the name, though this would be easy to add should it be necessary. For users of Mina that are deploying multiple times per day, date naming is probably not a feature they are interested in, at least with this implementation.

Potential enhancements for version naming that I could think of include 1) to add time to date, though this makes less sense for the purpose I described above, 2) potentially having 2 directory levels below *releases/*, the first being the date and the second being a sequenced set of deployments that occurred on that day. This enhancement would require a bit more work but would satisfy the requirement I described above while still providing a way of doing multiple deployments per day and 3) allowing users to specify a lambda function for *:version_scheme* which would effectively give a user full control over how the directories were named.