Any recommendations for deploying from SVN, with version numbers written to my code automatically?

I got convenience with SVN, and now I need a way to deploy my code faster to host or host servers. I also need some method for posting construction information in the footer of this site to help in testing. PHP / MySQL website.

+6
version-control php web-deployment-project
source share
8 answers

First enable keyword substitution for the file in which you want to get revision information:

svn propset svn:keywords "Rev" file.txt 

Add to the file where you want to save version information:

 $Rev$ 

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

+4
source share

Property methods will only give the latest version number of the file in which you have the property, and not the head revision of the entire repository (a la footer of the stack). If you want this, you will need to use svnversion .

I recently started using Capistrano in a project and it is superb and very flexible and powerful. I ended up pretty far from normal use, but greatly simplified the deployment of "click".

+3
source share

A script to update svn as needed.

SVN supports keywords. You can add which keywords you want to expand for the keywords property, and SVN will expand. See $ Id $ or $ Rev $ or keywords described in the SVN book.

+2
source share

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

CodeProject: Use Subversion Version Numbers in Visual Studio Projects

If you include SVN keywords, then every time you check the project, Subversion scans your files for specific “keywords” and replaces the keywords with some information.

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

'$ Posted by $
"$ Id: $
"$ Rev: $

When I test this file on Subversion, these keywords are replaced by the following:

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

+2
source share

I am a fan of using capistrano for jerks. See here .

You can use the SVN $ Rev $ property to get the version number in the footer.

+1
source share

In fact, an easy way to handle this is to configure the application as follows:

Just make the deployment application a working copy of your external line (project svn co to your root / www) and run svn up through the ssh console ( ssh user@host.com svn up /path/to/project ) when you need to upgrade. You can also roll back using appropriate verification mechanisms. This is important: if you do, add RewriteRules (or equivalent) to your .htaccess (or equivalent) to deny access to .svn directories . If you cannot do the above, run svn export via ssh instead (so that it will not be a “working copy”), but it will naturally be slower than doing up .

In addition, you can see what Ruby on Rails does with Capistrano .. this is the same basic concept, but supports transactional backups if the update fails in the middle, keeping each check in a separate folder and symbolically referring to the “latest” ones your directory / www.

0
source share

In most cases, the number of keywords will fail - for example, if you changed the source code before deployment or if you registered in one directory in your project, then another directory in the same project will have different version numbers. Check your documents carefully to make sure your keywords do what you think they do.

It is best to use the svnversion program to generate information about your checked directories during compilation or deployment. Svnversion will display version information of ALL of your directories, and also note whether the source has been changed locally.

0
source share

The method I came up with for my php projects may not be the best method, but after some time, it certainly seems like you need to do a check, run version check, destroy the .svn folders and move on. Here is the shell script part I wrote:

(you will need a script to check your repo first)

 # get the svn revision number and create a RELEASE file svnvers=`svnversion .` echo "version: $svnvers" echo "<release><development>0</development><revision>$svnvers</revision></release>" > RELEASE # remove all .svn directories find . -name .svn -exec rm -rf {} \; 
0
source share

All Articles