Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any recommendations for deployment from SVN, with version numbers written into my code automagically?

I've gotten comfy with SVN, and now I need a way to deploy my code to staging or live servers more easily. I'd also like some method for putting build info in the footer of this site to aid in testing. Site is PHP/MySQL.

like image 386
nickmjones Avatar asked Sep 15 '08 20:09

nickmjones


3 Answers

First enable keyword substitution for a file where you wish to have the revision info:

svn propset svn:keywords "Rev" file.txt

The add to the file where you want the Revision info stored:

$Rev$

Further readings: http://svnbook.red-bean.com/en/1.4/svn.advanced.props.special.keywords.html

like image 63
Staale Avatar answered Nov 01 '22 21:11

Staale


The properties methods will only give you the last revision number of the file you have the property in, not the head revision of the whole repository (a la the Stack Overflow footer). If you are wanting that, you'll need to use svnversion.

I recently started using Capistrano on a project and it superb and very flexible and powerful. I ended up deviating quite far from its normal usage, but it makes one "click" deployment much easier.

like image 3
reefnet_alex Avatar answered Nov 01 '22 21:11

reefnet_alex


If you want to update the version number in a projects AssemblyInfo.cs you may be interested in this article:

CodeProject: Use Subversion Revision numbers in your Visual Studio Projects

If you enable SVN Keywords then every time you check in the project Subversion scans your files for certain "keywords" and replaces the keywords with some information.

For example, At the top of my source files I would create a header contain the following keywords:

'$Author:$
'$Id:$
'$Rev:$

When I check this file into Subversion these keywords are replaced with the following:

'$Author: paulbetteridge $
'$Id: myfile.vb 145 2008-07-16 15:24:29Z paulbetteridge $
'$Rev: 145 $

like image 2
Eric Schoonover Avatar answered Nov 01 '22 22:11

Eric Schoonover