2011-04-26 03:57:55 +02:00
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
|
|
|
<!-- Installation instructions:
|
|
|
|
|
|
|
|
sudo pear install phing
|
|
|
|
sudo pear install VersionControl_Git-0.4.4
|
2011-04-26 05:41:25 +02:00
|
|
|
phing help
|
2011-04-26 03:57:55 +02:00
|
|
|
|
|
|
|
-->
|
|
|
|
|
|
|
|
<project name="silverstripe-installer" default="tag" phingVersion="2.4.5">
|
|
|
|
|
|
|
|
<!-- Load in the custom tasks -->
|
|
|
|
<taskdef name="findRepos" classname="tools.FindRepositoriesTask" classpath="${project.basedir}" />
|
|
|
|
<taskdef name="ssmodules" classname="tools.LoadModulesTask" classpath="${project.basedir}" />
|
|
|
|
<taskdef name="sschanglog" classname="tools.CreateChangelog" classpath="${project.basedir}" />
|
2011-04-28 05:47:48 +02:00
|
|
|
<taskdef name="gitstash" classname="tools.GitStashTask" classpath="${project.basedir}" />
|
2011-04-26 03:57:55 +02:00
|
|
|
|
|
|
|
<property name="basedir" value="." override="true" />
|
|
|
|
<property name="dependent-modules-file" value="dependent-modules" override="true" />
|
|
|
|
<property name="changelog-definitions-file" value="changelog-definitions" override="true" />
|
|
|
|
<property name="ni_build" value="false" override="true"/> <!-- Prompt if local changes would be overwritten by update -->
|
|
|
|
<property name="changelogSort" value="type" override="true"/>
|
2011-10-29 01:55:31 +02:00
|
|
|
|
|
|
|
<property name="archivedest" value="${basedir}/../" />
|
|
|
|
|
2011-04-26 03:57:55 +02:00
|
|
|
<available file="${dependent-modules-file}" property="dependent-modules-file-exists" />
|
|
|
|
<available file="${changelog-definition-file}" property="changelog-definition-file-exists" />
|
|
|
|
|
|
|
|
<target name="help">
|
|
|
|
<echo>
|
|
|
|
SilverStripe Project Build
|
|
|
|
------------------------------------
|
|
|
|
|
|
|
|
This build file contains targets to assist in creating new SilverStripe builds and releases.
|
|
|
|
|
2011-04-26 05:41:25 +02:00
|
|
|
Important targets:
|
2011-04-26 03:57:55 +02:00
|
|
|
|
2011-04-26 05:41:25 +02:00
|
|
|
* archive - Creates a tar.gz or zip file from the current source, removing version control specific files
|
|
|
|
* checkout - Switches all working copies to the specified tag or branch
|
2011-04-26 03:57:55 +02:00
|
|
|
* tag - Creates a new git tag in all the nested working copies (optionally pushes the created tag)
|
2011-04-26 05:41:25 +02:00
|
|
|
* pushtags - Pushes all local tags to their respective origin repositories
|
|
|
|
* update_modules - Checks out repositories defined in the 'dependent-modules' file into the current directory
|
|
|
|
* add_module - Checks out a module at a specific repository URL
|
|
|
|
* changelog - Create a changelog.md file from the repositories specified in the 'changelog-definitions' file
|
|
|
|
|
|
|
|
|
|
|
|
Options:
|
|
|
|
|
|
|
|
-Dbasedir = . (the base directory to operate on)
|
|
|
|
-Ddependent-modules-file = dependent-modules (the file of dependent modules to use when updating modules)
|
|
|
|
-Dchangelog-definitions-file = changelog-definitions (the file of changelog-definitions to use when generating the changelog)
|
|
|
|
-DchangelogSort = type (sort the changelog file by commit type)
|
|
|
|
-Dni_build = false (non-interactive build, overwrite local changes without prompting)
|
|
|
|
|
|
|
|
-Dmodurl (the URL of a single module to load when using add_modules)
|
|
|
|
-Dmodule (the name of the module directory to create the module in when using add_modules)
|
|
|
|
|
|
|
|
-Darchivetype (the type of archive to use zip or tar.giz)
|
|
|
|
-Darchivename (the name of the created archive file)
|
2011-10-29 01:55:31 +02:00
|
|
|
-Darchivedest (the destination directory to put the archive)
|
2011-04-26 05:41:25 +02:00
|
|
|
|
|
|
|
-Dtagname (the name of the tag/branch to check out or to create as a new tag)
|
|
|
|
-DincludeBaseDir (whether or not to include the base dir in a git checkout operation)
|
|
|
|
</echo>
|
2011-04-26 03:57:55 +02:00
|
|
|
</target>
|
|
|
|
|
|
|
|
<target name="gitRepositories">
|
|
|
|
<findRepos TargetDir="${basedir}" />
|
|
|
|
</target>
|
|
|
|
|
|
|
|
<!-- find the git binary and set it -->
|
|
|
|
<target name="gitBinary">
|
|
|
|
<exec command="which git" outputProperty="gitPath1" />
|
|
|
|
</target>
|
|
|
|
|
|
|
|
<!-- Tag a git repo with a specific tag (in $tagname) -->
|
|
|
|
<target name="tagTask" if="tagname,reponame,gitPath1">
|
|
|
|
<gittag
|
|
|
|
repository="${reponame}"
|
|
|
|
name="${tagname}"
|
|
|
|
gitPath="${gitPath1}"
|
|
|
|
force="true" /> <!-- allow overwrite of existing tags-->
|
|
|
|
<echo msg="git tag '${tagname}' added to '${reponame}' git repository" />
|
|
|
|
</target>
|
|
|
|
|
|
|
|
<!-- Push all local tags -->
|
|
|
|
<target name="pushTask" if="reponame,gitPath1">
|
|
|
|
<gitpush
|
|
|
|
repository="${reponame}"
|
|
|
|
tags="true"
|
|
|
|
gitPath="${gitPath1}" />
|
|
|
|
<echo msg="pushed all tags to '${reponame}' git repository" />
|
|
|
|
</target>
|
|
|
|
|
|
|
|
<!-- Checkout the specified tag on all working copies -->
|
|
|
|
<target name="checkoutTask" if="reponame,gitPath1,tagname">
|
2011-04-28 05:47:48 +02:00
|
|
|
<echo msg="checking out ${reponame}"/>
|
|
|
|
<gitstash repository="${reponame}" gitPath="${gitPath1}" />
|
|
|
|
|
2011-04-26 03:57:55 +02:00
|
|
|
<gitcheckout
|
|
|
|
repository="${reponame}"
|
|
|
|
branchname="${tagname}"
|
|
|
|
gitPath="${gitPath1}" />
|
2011-04-28 05:47:48 +02:00
|
|
|
|
|
|
|
<gitstash repository="${reponame}" gitPath="${gitPath1}" pop="true" />
|
|
|
|
|
2011-04-26 03:57:55 +02:00
|
|
|
<echo msg="checked out ${tagname} tag/branch in '${reponame}' git repository" />
|
|
|
|
</target>
|
|
|
|
|
|
|
|
<target name="createDependentModulesFile" unless="dependent-modules-file-exists">
|
|
|
|
<copy file="${dependent-modules-file}.default" tofile="${dependent-modules-file}" />
|
|
|
|
</target>
|
|
|
|
|
|
|
|
<target name="createChangelogDefinitionsFile" unless="changelog-definitions-file-exists">
|
|
|
|
<copy file="${changelog-definitions-file}.default" tofile="${changelog-definitions-file}" />
|
|
|
|
</target>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- tags all git repositories in the current directory with a tag name -->
|
|
|
|
<target name="tag" if="basedir" depends="gitRepositories,gitBinary">
|
|
|
|
<if>
|
|
|
|
<isset property="tagname"/>
|
|
|
|
<then>
|
|
|
|
<echo msg="Using '${tagname}' tag"/>
|
|
|
|
</then>
|
|
|
|
<else>
|
|
|
|
<input propertyName="tagname" promptChar=":">Please enter the name of the tag</input>
|
|
|
|
<echo msg="Using '${tagname}' tag"/>
|
|
|
|
</else>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<!-- find all git repos and run the tagTask on them -->
|
|
|
|
<foreach list="${GitReposList}" param="reponame" target="tagTask" />
|
|
|
|
|
|
|
|
<input propertyName="pushToOrigin" defaultValue="no" validArgs="yes,no" promptChar=":">Push local tags to origin?</input>
|
|
|
|
<if>
|
|
|
|
<equals arg1="${pushToOrigin}" arg2="yes" casesensitive="false" trim="true"/>
|
|
|
|
<then>
|
2011-04-26 05:41:25 +02:00
|
|
|
<phingCall target="pushtags" />
|
2011-04-26 03:57:55 +02:00
|
|
|
</then>
|
|
|
|
</if>
|
|
|
|
</target>
|
|
|
|
|
|
|
|
<!-- Pushes all local tags to origin -->
|
2011-04-26 05:41:25 +02:00
|
|
|
<target name="pushtags" if="basedir" depends="gitRepositories,gitBinary">
|
2011-04-26 03:57:55 +02:00
|
|
|
<foreach list="${GitReposList}" param="reponame" target="pushTask" />
|
|
|
|
</target>
|
|
|
|
|
|
|
|
<!-- Switches all working copies to the specified tag or branch -->
|
|
|
|
<target name="checkout" if="basedir" depends="gitRepositories,gitBinary">
|
|
|
|
<if>
|
|
|
|
<isset property="tagname"/>
|
|
|
|
<then>
|
|
|
|
<echo msg="Using '${tagname}' tag/branch"/>
|
|
|
|
</then>
|
|
|
|
<else>
|
|
|
|
<input propertyName="tagname" defaultValue="HEAD" promptChar=":">Please enter the name of the tag or branch you wish to checkout</input>
|
|
|
|
<echo msg="Using '${tagname}' tag/branch"/>
|
|
|
|
</else>
|
|
|
|
</if>
|
|
|
|
|
2011-04-28 05:47:48 +02:00
|
|
|
<if>
|
|
|
|
<isset property="includeBaseDir"/>
|
|
|
|
<then>
|
|
|
|
<echo msg="Including BaseDir in checkout: ${includeBaseDir}"/>
|
|
|
|
</then>
|
|
|
|
<else>
|
|
|
|
<input propertyName="includeBaseDir" validArgs="yes,no" promptChar=":">Include the base dir '${basedir}' in checkout?</input>
|
|
|
|
<echo msg="Including BaseDir in checkout: ${includeBaseDir}"/>
|
|
|
|
</else>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<if>
|
|
|
|
<isfalse value="${includeBaseDir}"/>
|
|
|
|
<then><!-- get a list of git repos without the base dir -->
|
|
|
|
<findRepos TargetDir="${basedir}" includeTarget="${includeBaseDir}"/>
|
|
|
|
</then>
|
|
|
|
</if>
|
|
|
|
|
2011-04-26 03:57:55 +02:00
|
|
|
<!-- find all git repos and run the checkoutTask on them -->
|
|
|
|
<foreach list="${GitReposList}" param="reponame" target="checkoutTask" />
|
|
|
|
</target>
|
|
|
|
|
2012-02-01 17:54:36 +01:00
|
|
|
<target name="archive" if="basedir" description="Creates a gzip archive from the current folder (removes any version control files)">
|
2012-02-01 18:15:29 +01:00
|
|
|
|
|
|
|
<if>
|
|
|
|
<not><isset property="version"/></not>
|
|
|
|
<then><input propertyName="version" defaultValue="x.y.z" promptChar=":">Please choose a version</input></then>
|
|
|
|
</if>
|
|
|
|
|
2011-04-26 03:57:55 +02:00
|
|
|
<if>
|
|
|
|
<isset property="archivetype"/>
|
|
|
|
<then>
|
|
|
|
<echo msg="Creating '${archivetype}' archive"/>
|
|
|
|
</then>
|
|
|
|
<else>
|
|
|
|
<input propertyName="archivetype" defaultValue="tar.gz" validArgs="tar.gz,zip" promptChar=":">Please choose archive format</input>
|
|
|
|
<echo msg="Creating '${archivetype}' archive"/>
|
|
|
|
</else>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<if>
|
|
|
|
<isset property="archivename"/>
|
|
|
|
<then>
|
|
|
|
<echo msg="Creating '${archivename}' archive"/>
|
|
|
|
</then>
|
|
|
|
<else>
|
2012-02-01 18:15:29 +01:00
|
|
|
<input propertyName="archivename" defaultValue="SilverStripe-v${version}" promptChar=":">Please enter a name for the archive (without extension)</input>
|
2011-04-26 03:57:55 +02:00
|
|
|
<echo msg="Creating '${archivename}' archive"/>
|
|
|
|
</else>
|
|
|
|
</if>
|
|
|
|
|
2011-10-29 01:08:22 +02:00
|
|
|
<property name="archivefilename" value="${archivename}.${archivetype}" />
|
|
|
|
|
2012-02-01 17:54:36 +01:00
|
|
|
<!-- Copy into a new folder, and tar the whole folder in order to avoid toplevel extracts -->
|
|
|
|
<php function="sys_get_temp_dir" returnProperty="systmp" />
|
|
|
|
<property name="tmp" value="${systmp}/archiveTask/" />
|
|
|
|
|
|
|
|
<copy todir="${tmp}/${archivename}">
|
|
|
|
<fileset dir="${basedir}">
|
|
|
|
<include name="**/**" />
|
|
|
|
<exclude name="assets/**" />
|
|
|
|
<exclude name="mysite/local.conf.php" />
|
|
|
|
<exclude name="mysite/db.conf.php" />
|
|
|
|
<exclude name="**/*.log" />
|
|
|
|
<exclude name="**/.svn/**" />
|
|
|
|
<exclude name="**/.git/**" />
|
|
|
|
<exclude name="**/.project" /> <!-- remove eclipse configuration file -->
|
|
|
|
<exclude name="**/.buildpath" />
|
|
|
|
<exclude name="**/.settings" />
|
|
|
|
<exclude name="**/.idea/**" /> <!-- remove phpstorm configuration file -->
|
|
|
|
<exclude name="tools/**" />
|
|
|
|
<exclude name="**/tests/**" />
|
|
|
|
<exclude name="cms/docs/**" />
|
|
|
|
<exclude name="sapphire/docs/**" />
|
|
|
|
<exclude name="build.xml" />
|
|
|
|
<exclude name="dependent-modules*" />
|
|
|
|
<exclude name="changelog-definitions*" />
|
|
|
|
<exclude name="_ss_environment.php" />
|
|
|
|
</fileset>
|
|
|
|
<fileset dir="${basedir}">
|
|
|
|
<include name="assets/Uploads" />
|
|
|
|
<include name="assets/.htaccess" />
|
|
|
|
<include name="assets/web.config" />
|
|
|
|
</fileset>
|
|
|
|
</copy>
|
|
|
|
|
|
|
|
<!-- TODO Remove once we figured out how to nest git repositories for themes -->
|
|
|
|
<move file="${tmp}/${archivename}/themes/blackcandy/blackcandy_blog" todir="${tmp}/${archivename}/themes" haltonerror='false' />
|
|
|
|
<move file="${tmp}/${archivename}/themes/blackcandy/blackcandy_calendar" todir="${tmp}/${archivename}/themes" haltonerror='false' />
|
|
|
|
<move file="${tmp}/${archivename}/themes/blackcandy/blackcandy" todir="${tmp}/${archivename}/themes" haltonerror='false' />
|
|
|
|
|
|
|
|
<!-- create tar archive -->
|
|
|
|
<if>
|
|
|
|
<equals arg1="${archivetype}" arg2="tar.gz" casesensitive="false" trim="true"/>
|
|
|
|
<then>
|
|
|
|
<tar destfile="${archivedest}/${archivefilename}" compression="gzip">
|
|
|
|
<fileset dir="${tmp}">
|
|
|
|
<include name="**/**" />
|
|
|
|
</fileset>
|
|
|
|
</tar>
|
|
|
|
</then>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<!-- create zip archive -->
|
|
|
|
<if>
|
|
|
|
<equals arg1="${archivetype}" arg2="zip" casesensitive="false" trim="true"/>
|
|
|
|
<then>
|
|
|
|
<zip destfile="${archivedest}/${archivefilename}">
|
|
|
|
<fileset dir="${tmp}">
|
|
|
|
<include name="**/**" />
|
|
|
|
</fileset>
|
|
|
|
</zip>
|
|
|
|
</then>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<delete dir="${tmp}" />
|
|
|
|
|
2011-05-02 01:56:38 +02:00
|
|
|
<echo msg="Created archive in: ${basedir}/${archivename}" />
|
2011-04-26 03:57:55 +02:00
|
|
|
</target>
|
|
|
|
|
|
|
|
<!-- Load modules where sensitive dependency exists -->
|
|
|
|
<target name="update_modules" depends="createDependentModulesFile">
|
|
|
|
<ssmodules file="${basedir}/${dependent-modules-file}" noninteractive="${ni_build}"/>
|
|
|
|
</target>
|
|
|
|
|
|
|
|
<!-- Add a new module to the system. Run from the commandline, you can pass
|
|
|
|
in the details of the module as phing add_module -Dmodule=blog -Dmodurl=http://path/to/svn -->
|
|
|
|
<target name="add_module">
|
|
|
|
<if>
|
|
|
|
<isset property="modurl"/>
|
|
|
|
<then>
|
|
|
|
<echo msg="Downloading module from '${modurl}'"/>
|
|
|
|
</then>
|
|
|
|
<else>
|
|
|
|
<input propertyName="modurl" promptChar=":">Please enter the module's git or svn URL</input>
|
|
|
|
<echo msg="Downloading module from '${modurl}'"/>
|
|
|
|
</else>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<if>
|
|
|
|
<isset property="module"/>
|
|
|
|
<then>
|
|
|
|
<echo msg="Creating new '${module}' module"/>
|
|
|
|
</then>
|
|
|
|
<else>
|
|
|
|
<input propertyName="module" promptChar=":">Please enter the module's name (i.e. the folder to module should be created in)</input>
|
|
|
|
<echo msg="Creating new '${module}' module"/>
|
|
|
|
</else>
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<ssmodules name="${module}" url="${modurl}" />
|
|
|
|
</target>
|
|
|
|
|
|
|
|
<!-- Create a changelog of git changes based on the -->
|
2011-05-01 08:30:37 +02:00
|
|
|
<target name="changelog" depends="createChangelogDefinitionsFile" if="basedir,changelogSort">
|
2011-04-26 03:57:55 +02:00
|
|
|
<sschanglog definitions="${changelog-definitions-file}" baseDir="${basedir}" sort="${changelogSort}"/>
|
2011-05-01 08:30:37 +02:00
|
|
|
<echo msg="${changelogOutput}" />
|
2011-04-26 03:57:55 +02:00
|
|
|
</target>
|
|
|
|
|
|
|
|
</project>
|