silverstripe-installer/build.xml

485 lines
20 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="UTF-8"?>
<!-- Installation instructions:
sudo pear channel-discover pear.phing.info
sudo pear install phing/phing
sudo pear install pear/VersionControl_Git-0.4.4
phing help
-->
<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}" />
<taskdef name="gitstash" classname="tools.GitStashTask" classpath="${project.basedir}" />
<taskdef name="updateTranslationsTask" classname="tools.UpdateTranslationsTask" classpath="${project.basedir}" />
<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"/>
<property name="archivedest" value="." />
<available file="${dependent-modules-file}" property="dependent-modules-file-exists" />
<available file="${changelog-definition-file}" property="changelog-definition-file-exists" />
<!--
=================================================================
Helper Targets
=================================================================
-->
<target name="help">
<echo>
SilverStripe Project Build
------------------------------------
This build file contains targets to assist in creating new SilverStripe builds and releases.
Run "phing -l" to get a full list of available targets.
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)
-Darchivename (the name of the created archive file)
-Darchivedest (the destination directory to put the archive)
-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>
</target>
<target name="_gitRepositories">
<findRepos TargetDir="${basedir}" />
</target>
<target name="_gitBinary" description="find the git binary and set it">
<exec command="which git" outputProperty="gitPath1" />
</target>
<target name="_tagTask" if="tagname,reponame,gitPath1"
description="Tag a git repo with a specific tag.">
<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>
<target name="_pushTask" if="reponame,gitPath1"
description="Push all local tags">
<ssgitpush
repository="${reponame}"
tags="true"
gitPath="${gitPath1}" />
<echo msg="pushed all tags to '${reponame}' git repository" />
</target>
<target name="_checkoutTask" if="reponame,gitPath1,tagname"
description="Checkout the specified tag on all working copies">
<echo msg="checking out ${reponame}"/>
<gitstash repository="${reponame}" gitPath="${gitPath1}" />
<ssgitcheckout
repository="${reponame}"
branchname="${tagname}"
gitPath="${gitPath1}" />
<gitstash repository="${reponame}" gitPath="${gitPath1}" pop="true" />
<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>
<!--
=================================================================
Main Targets
=================================================================
-->
<target name="tag" if="basedir"
description="Creates a new git tag in all the nested working copies (optionally pushes the created tag)"
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>
<phingCall target="pushtags" />
</then>
</if>
</target>
<target name="pushtags" if="basedir"
description="Pushes all local tags to their respective origin repositories"
depends="_gitRepositories,_gitBinary">
<foreach list="${GitReposList}" param="reponame" target="_pushTask" />
</target>
<target name="checkout" if="basedir"
description="Switches all working copies to the specified tag or branch"
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>
<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>
<!-- find all git repos and run the checkoutTask on them -->
<foreach list="${GitReposList}" param="reponame" target="_checkoutTask" />
</target>
<target name="archive" if="basedir" description="Creates a gzip archive from the current folder (removes any version control files)">
<if>
<not><isset property="version"/></not>
<then><input propertyName="version" defaultValue="x.y.z" promptChar=":">Please choose a version</input></then>
</if>
<if>
<isset property="archivename"/>
<then>
<echo msg="Creating '${archivename}' archive"/>
</then>
<else>
<property name="archivename" value="SilverStripe" />
</else>
</if>
<!-- 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/" />
<delete dir="${tmp}" failonerror="false" quiet="true" />
<copy todir="${tmp}/${archivename}-cms-v${version}">
<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="framework/docs/**" />
<exclude name="build.xml" />
<exclude name="dependent-modules*" />
<exclude name="changelog-definitions*" />
<exclude name="_ss_environment.php" />
<exclude name="*.tar.gz" />
<exclude name="*.zip" />
</fileset>
<fileset dir="${basedir}">
<include name="assets/Uploads" />
<include name="assets/.htaccess" />
<include name="assets/web.config" />
</fileset>
</copy>
<copy todir="${tmp}/${archivename}-framework-v${version}">
<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="framework/docs/**" />
<exclude name="build.xml" />
<exclude name="dependent-modules*" />
<exclude name="changelog-definitions*" />
<exclude name="_ss_environment.php" />
<exclude name="*.tar.gz" />
<exclude name="*.zip" />
<exclude name="cms/**" />
</fileset>
<fileset dir="${basedir}">
<include name="assets/Uploads" />
<include name="assets/.htaccess" />
<include name="assets/web.config" />
</fileset>
</copy>
<!-- Write version info to the core folders (shouldn't be in version control) -->
<echo msg="${version}" file="${tmp}/${archivename}-cms-v${version}/framework/silverstripe_version" />
<echo msg="${version}" file="${tmp}/${archivename}-cms-v${version}/cms/silverstripe_version" />
<echo msg="${version}" file="${tmp}/${archivename}-cms-v${version}/framework/silverstripe_version" />
<!-- remove any pre-existing archives -->
<delete file="${archivedest}/${archivename}-cms-v${version}.tar.gz" failonerror="false" quiet="true" />
<delete file="${archivedest}/${archivename}-cms-v${version}.zip" failonerror="false" quiet="true" />
<delete file="${archivedest}/${archivename}-framework-v${version}.tar.gz" failonerror="false" quiet="true" />
<delete file="${archivedest}/${archivename}-framework-v${version}.zip" failonerror="false" quiet="true" />
<!-- create tar archive - CMS -->
<tar destfile="${archivedest}/${archivename}-cms-v${version}.tar.gz" compression="gzip">
<fileset dir="${tmp}">
<include name="${archivename}-cms-v${version}/**" />
</fileset>
</tar>
<!-- create zip archive - CMS -->
<zip destfile="${archivedest}/${archivename}-cms-v${version}.zip">
<fileset dir="${tmp}">
<include name="${archivename}-cms-v${version}/**" />
</fileset>
</zip>
<!-- create tar archive - Framework -->
<tar destfile="${archivedest}/${archivename}-framework-v${version}.tar.gz" compression="gzip">
<fileset dir="${tmp}">
<include name="${archivename}-framework-v${version}/**" />
</fileset>
</tar>
<!-- create zip archive - Framework -->
<zip destfile="${archivedest}/${archivename}-framework-v${version}.zip">
<fileset dir="${tmp}">
<include name="${archivename}-framework-v${version}/**" />
</fileset>
</zip>
<!-- clear the temp file -->
<delete file="${tmp}" failonerror="false" quiet="true" />
<echo msg="Created archive: ${archivedest}/${archivename}-cms-v${version}.tar.gz" />
<echo msg="##teamcity[publishArtifacts '${archivename}-cms-v${version}.tar.gz']" />
<echo msg="Created archive: ${archivedest}/${archivename}-cms-v${version}.zip" />
<echo msg="##teamcity[publishArtifacts '${archivename}-cms-v${version}.zip']" />
<echo msg="Created archive: ${archivedest}/${archivename}-framework-v${version}.tar.gz" />
<echo msg="##teamcity[publishArtifacts '${archivename}-framework-v${version}.tar.gz']" />
<echo msg="Created archive: ${archivedest}/${archivename}-framework-v${version}.tar.gz" />
<echo msg="##teamcity[publishArtifacts '${archivename}-framework-v${version}.zip']" />
</target>
<target name="upload-release"
description="Uploads archives previously created through 'ping archive' to a public webhost, and notifies a group of people of the new release. Requires working public key auth on the release destination.">
<if>
<not><isset property="version"/></not>
<then><input propertyName="version" defaultValue="x.y.z" promptChar=":">Please choose a version</input></then>
</if>
2012-06-18 08:08:00 +02:00
<property name="release_dest" value="qa-servers@homer:/sites/ssorg-v2/www/assets/releases/" />
<property name="release_url" value="http://silverstripe.org/assets/releases/" />
<property name="release_notify_list" value="all@silverstripe.com,everyone@silverstripe.com.au" />
<exec command="scp -P 2222 SilverStripe-cms-v${version}.tar.gz SilverStripe-framework-v${version}.tar.gz SilverStripe-cms-v${version}.zip SilverStripe-framework-v${version}.zip ${release_dest}" checkreturn="true" logoutput="true" />
<mail from="reports@silverstripe.com" tolist="${release_notify_list}" subject="SilverStripe ${version} has been uploaded">A new SilverStripe release is ready, and although it hasn't been publicly announced yet, is available at the following locations:
${release_url}SilverStripe-cms-v${version}.tar.gz
${release_url}SilverStripe-framework-v${version}.tar.gz
${release_url}SilverStripe-cms-v${version}.zip
${release_url}SilverStripe-framework-v${version}.zip
Thanks,
Your friendly automated release script.
</mail>
</target>
<target name="upload-nightly"
description="Uploads archives previously created through 'phing archive' to a public webhost">
<property name="nightly_dest" value="qa-servers@homer:/sites/ssorg-v2/www/assets/nightlies/" />
<exec command="scp -P 2222 SilverStripe-*.tar.gz ${nightly_dest}" />
<exec command="scp -P 2222 SilverStripe-*.zip ${nightly_dest}" />
</target>
<target name="update_modules"
description="Checks out repositories defined in the 'dependent-modules' file into the current directory"
depends="_createDependentModulesFile">
<ssmodules file="${basedir}/${dependent-modules-file}" noninteractive="${ni_build}"/>
</target>
<target name="add_module" description="Checks out a module at a specific repository URL. Usage: phing add_module -Dmodule=blog -Dmodurl=http://path/to/svn.">
<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>
<target name="changelog"
description="Create a changelog.md file from the repositories specified in the 'changelog-definitions' file"
depends="_createChangelogDefinitionsFile"
if="basedir,changelogSort">
<sschanglog definitions="${changelog-definitions-file}" baseDir="${basedir}" sort="${changelogSort}"/>
<echo msg="${changelogOutput}" />
</target>
<target name="translations-staging-setup">
<propertyprompt propertyName="module"
promptText="Module name?"
useExistingValue="true" />
<propertyprompt propertyName="getlocalization.${module}.project"
promptText="getlocalization project"
useExistingValue="true" />
<propertyprompt propertyName="getlocalization.${module}.user"
promptText="getlocalization username"
useExistingValue="true" />
<propertyprompt propertyName="getlocalization.${module}.password"
promptText="getlocalization password"
useExistingValue="true" />
<exec command="git checkout master" dir="${module}" checkreturn="true" />
<exec command="git fetch origin" dir="${module}" checkreturn="true" />
<exec command="git branch --force --track translation-staging origin/translation-staging" dir="${module}" checkreturn="true" />
<exec command="git checkout translation-staging" dir="${module}" checkreturn="true" />
</target>
<target name="translations-staging-teardown">
<exec command="git checkout master" dir="${module}" checkreturn="true" />
</target>
<target name="translations-update-git-masterfile"
description="Collect translation on a module, commit them into a specialized branch and push to the origin repository."
depends="translations-staging-setup">
<exec command="git merge origin/master" dir="${module}" checkreturn="true" />
<exec command="php framework/cli-script.php dev/tasks/i18nTextCollectorTask" passthru="true" />
<exec command="git status --short" dir="${module}" outputProperty="git.status.${module}" />
<if>
<istrue value="${git.status.${module}}" />
<then>
<exec command="git add lang/*" dir="${module}" passthru="true" checkreturn="true" />
<exec command="git commit -m 'MINOR Updated translations master'" dir="${module}" passthru="true" checkreturn="true" />
<exec command="git merge origin/master" dir="${module}" checkreturn="true" />
</then>
</if>
</target>
<target name="translations-update-gl-masterfile"
description="Pushes translation master files to getlocalization.com"
depends="translations-staging-setup">
<exec command="curl --fail --form file=@${module}/lang/en.yml --form name='lang/en.yml' --user ${getlocalization.${module}.user}:${getlocalization.${module}.password} https://api.getlocalization.com/${getlocalization.${module}.project}/api/update-master/" passthru="true" checkreturn="true" />
<exec command="git checkout master" dir="${module}" checkreturn="true" />
</target>
<target name="translations-update-gl-contribs" description="Update translations in working copy from getlocalization.com, and commit changes to a specialized branch and push to origin repository. Note: The API requests can take a couple of minutes."
depends="translations-staging-setup">
<exec command="git stash" dir="${module}" checkreturn="true" />
<updateTranslationsTask
glProductName="${getlocalization.${module}.project}"
glUser="${getlocalization.${module}.user}"
glPassword="${getlocalization.${module}.password}"
modulePath="${module}"
/>
<exec command="git status --short" dir="${module}" outputProperty="git.status.${module}" />
<if>
<istrue value="${git.status.${module}}" />
<then>
<exec command="git add lang/*" dir="${module}" passthru="true" checkreturn="true" />
<exec command="git add javascript/lang/*" dir="${module}" passthru="true" checkreturn="true" />
<exec command="git commit -m 'MINOR Updated translations'" dir="${module}" passthru="true" checkreturn="true" />
<exec command="git push origin translation-staging" dir="${module}" checkreturn="true" />
</then>
</if>
<exec command="git checkout master" dir="${module}" checkreturn="true" />
<exec command="git stash pop" dir="${module}" checkreturn="true" />
</target>
<target name="translations-sync"
description="Wrapper task to handle updating translations and master files, using the getlocalization.com API, committing to a specialized branch in the working copy and pushing to the origin repository.">
<foreach list="framework,cms" param="module" target="translations-update-git-masterfile" />
<foreach list="framework,cms" param="module" target="translations-update-gl-masterfile" />
<foreach list="framework,cms" param="module" target="translations-update-gl-contribs" />
</target>
</project>