Published on

Saving version number at capifony deploy


Having a git version number and deploydate is very convenient to keep tabs on the deployed software on your different environments. To save the version number to a json file during deployment, use the following capifony task.

namespace :deploy do
desc "write version number to app-readable file"
task :write_versionfile, :roles => :app do
versionobject = {
:version => "#{capture("cd #{release_path} && git describe")}",
:deploydate =>
versionobjectjson = versionobject.to_json.gsub(/\\n/,"")
run "echo '#{versionobjectjson}' > #{release_path}/web/VERSION"

after 'deploy:update_code', 'deploy:write_versionfile'