Created
August 26, 2014 10:10
-
-
Save Schlaefer/3826aed4e659e433df38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<project name="PhileCMS" default="menu"> | |
<property name="dirs.dist" value="dist"/> | |
<property name="dirs.build" value="phing-temp"/> | |
<property name="dirs.git" value="${dirs.build}/Phile"/> | |
<property name="git.url" value="https://github.com/PhileCMS/Phile.git"/> | |
<!-- ## menu ## --> | |
<target name="menu"> | |
<echo msg="1) build distribution .zip (remote origin as source)"/> | |
<echo msg="2) build phpdoc in docs/ (local checkout as source)"/> | |
<echo msg="3) update homepage (local checkout as source, pushes to origin)"/> | |
<echo msg=" - updates phpdoc in api/"/> | |
<echo msg="q) quit"/> | |
<input message="Choose" propertyName="choice" validArgs="1,2,3,q"/> | |
<if> | |
<equals arg1="${choice}" arg2="1"/> | |
<then><phingcall target="dist"/></then> | |
<elseif> | |
<equals arg1="${choice}" arg2="2"/> | |
<then><phingcall target="phpdoc"/></then> | |
</elseif> | |
<elseif> | |
<equals arg1="${choice}" arg2="3"/> | |
<then><phingcall target="homepage-release"/></then> | |
</elseif> | |
</if> | |
</target> | |
<!-- ## helper ## --> | |
<target name="remove-build-dir"> | |
<delete dir="${dirs.build}" includeemptydirs="true" quiet="true"/> | |
</target> | |
<target name="clean-build-dir" depends="remove-build-dir"> | |
<delete dir="${dirs.build}" includeemptydirs="true" quiet="true"/> | |
<mkdir dir="${dirs.build}"/> | |
</target> | |
<!-- git checkout into temp directory --> | |
<target name="git-checkout" depends="clean-build-dir"> | |
<echo msg="Checkout git branch ${branch}"/> | |
<exec command="git clone -b ${branch} ${git.url}" dir="${dirs.build}"/> | |
<if> | |
<not> | |
<equals arg1="${tag}" arg2="head"/> | |
</not> | |
<then> | |
<echo msg="Switch to git tag ${tag}"/> | |
<exec command="git checkout tags/${tag}" dir="${dirs.git}"/> | |
</then> | |
</if> | |
</target> | |
<!-- ## dist ## --> | |
<target name="create-dirs" depends="clean-build-dir"> | |
<echo msg="Creating build + dist directories."/> | |
<delete dir="${dirs.dist}" includeemptydirs="true"/> | |
<mkdir dir="${dirs.dist}"/> | |
</target> | |
<target name="dist"> | |
<fileset id="release-fileset" dir="${dirs.git}"> | |
<include name=".editorconfig"/> | |
<include name=".htaccess"/> | |
<include name="Changelog.md"/> | |
<include name="config.php"/> | |
<include name="content/**"/> | |
<include name="default_config.php"/> | |
<include name="generator.php"/> | |
<include name="Icon.png"/> | |
<include name="index.php"/> | |
<include name="lib/**"/> | |
<include name="LICENSE"/> | |
<include name="plugins/**"/> | |
<include name="README.md"/> | |
<include name="themes/**"/> | |
<exclude name="lib/vendor/twig/twig/doc/**"/> | |
<exclude name="lib/vendor/twig/twig/ext/**"/> | |
<exclude name="lib/vendor/twig/twig/test/**"/> | |
</fileset> | |
<input propertyName="git.branch" defaultValue="master" message="Remote git branch to use?"></input> | |
<input propertyName="git.tag" defaultValue="head" message="Tag to use?"></input> | |
<phingcall target="create-dirs"/> | |
<phingcall target="git-checkout"> | |
<property name="branch" value="${git.branch}" /> | |
<property name="tag" value="${git.tag}" /> | |
</phingcall> | |
<echo msg="Install composer packages"/> | |
<exec command="composer install --optimize-autoloader --no-dev" | |
dir="${dirs.git}"/> | |
<echo msg="Creating Zip"/> | |
<php expression="str_replace('/', '-', '${git.branch}');" returnProperty="git.branch.clean"/> | |
<zip destfile="${dirs.dist}/phile-${git.branch.clean}-${git.tag}.zip" basedir="${dirs.git}"> | |
<fileset refid="release-fileset"/> | |
</zip> | |
<phingcall target="clean-build-dir"/> | |
</target> | |
<!-- ## phpdoc ## --> | |
<target name="phpdoc"> | |
<echo msg="Create phpdoc in docs/"/> | |
<delete dir="docs" includeemptydirs="true"/> | |
<mkdir dir="docs"/> | |
<phpdoc2 destdir="docs" template="clean"> | |
<fileset dir="${project.basedir}"> | |
<include name="lib/Phile/**/*.php"/> | |
<include name="plugins/phile/**/*.php"/> | |
<exclude name="plugins/phile/phpFastCache/lib/phpfastcache/**"/> | |
</fileset> | |
</phpdoc2> | |
</target> | |
<!-- ## updates homepage ## --> | |
<target name="homepage-release"> | |
<!-- checkout homepage --> | |
<phingcall target="git-checkout"> | |
<property name="branch" value="gh-pages" /> | |
<property name="tag" value="head" /> | |
</phingcall> | |
<!-- updates api/ documentation --> | |
<phingcall target="phpdoc"/> | |
<property name="dirs.api" value="${dirs.git}/api" /> | |
<delete dir="${dirs.api}" includeemptydirs="true"/> | |
<mkdir dir="${dirs.api}"/> | |
<copy todir="${dirs.api}" overwrite="true"> | |
<fileset dir="docs/" includes="**"></fileset> | |
</copy> | |
<exec dir='${dirs.api}' command="git add --all .; git commit -m 'updates api/ documentation';"/> | |
<delete dir="docs"/> | |
<!-- push homepage & cleanup --> | |
<exec dir='${dirs.git}' command="git push origin gh-pages"/> | |
<phingcall target="remove-build-dir"/> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment