Use continuous integration software like TeamCity, and use a build script that accepts the version number as a parameter. Your build script may just call a little tool that just does: open a file (versioninfo.php), search this string (some regex stuff), and replace it with the given parameter.
Some additional hints for making this more easy: Branch every version that is soon to be released, we have 5.0 on production right now (but it's still built for the purpose of hotfixing), 5.1 is branched and is tested at this point, and the trunk contains the 5.2.
Everytime you will need to release a hotfix, update the version number in TeamCity, and in the call to the build script (which also should be done in TeamCity).
F.e. We have the following projects at this point:
- Release 5.0.5 (which takes /v=5.0.5)
- Release 5.1 (which takes /v=5.1)
- Trunk (which takes /v=5.2)
Combine this with prefixing your SQL scripts with the version number, and an automated database generating script, that creates a big transaction script per version (like: 'DPL_Updates_for_5.1.sql').
When we are bringing a version to production, we take the artifacts from the branch from TeamCity, the database-scripts which are specific for that version are automatically added to the zip-file, and we give the file (plus release notes, etc.) to our application management department.