Automatic release script from Subversion (SVN)

Shell Script

Simple script to manage the release from Subersion to site process, and create a version file _vni_ that simply contains the current release version information for easy display by including into PHP (or via whatever other include method is available).

#!/bin/ksh
svn update
svn status
svn info | awk -f make-vers.awk
# mysql -uroot <mysql\ databases/db-create.sql

AWK script to process SVN output

The following small script parses the result of *svn info* and produces a small _vni_ file that contains the site build / release information. It will have a different background colour for each release together with the date that the release was made.

BEGIN{
    cols[ci++] = "#3300FF";
    cols[ci++] = "#B300FF";
    cols[ci++] = "#FF00CC";
    cols[ci++] = "#FF004D";
    cols[ci++] = "#FF3300";
    cols[ci++] = "#FFB300";
    cols[ci++] = "#CC8800";
    cols[ci++] = "#4D8800";
    cols[ci++] = "#008833";
    cols[ci++] = "#0088B3";
    cols[ci++] = "#00CC88";
    cols[ci++] = "#004D88";
    cols[ci++] = "#643D88";
    cols[ci++] = "#957A88";
    cols[ci++] = "#D8883D";
    cols[ci++] = "#E4887A";
}
/^Revision\:/{rev = $2}
/^Last Changed Author\:/{auth=$4}
/^Last Changed Date\:/{date=$4}

END{
    date = strftime("%d-%b-%Y")
    col = cols[rev%ci]
    vs = "<div id='vni'>\n";
    vs = vs "<p style='background-color: "col"'>BuildInfo: SiteName V2.0 Production: Release "
    vs = vs (rev)
    vs = vs " - " date
    vs = vs " ("auth") "
    vs = vs "</p>\n</div>"

    OF="vni"
    print vs >OF;
}

Example version number information bar.

The following is the typical output which contains all of the information needed to track a sites release. I find it very useful to put this in the footer of the admin (or help) section, and the changing colour really helps me to identify when the site has been changed.

BuildInfo: Sitename V2.0 Production: Release 373 - 29-Dec-2010 (richard)