Jan 12 2011

Exporting a git tag in a Phing target and subsequently processing the files

Composing releases with git archive is very useful, especially when making use of the .gitattributes file to select what is archived.

One way to make use of this command in Phing, is to do the following:

<target name="build" depends="prepare">
    <exec command="git archive ${git_tag} | tar -x -C ./_build" />
</target>

This allows processing of the archived files. For example, the target could be expanded to strip PHP comments:

<target name="build" depends="prepare">
    <exec command="git archive ${git_tag} | tar -x -C ./_build" />

    <reflexive>
        <fileset dir="./_build">
            <include pattern="**/*.php" />
        </fileset>
        <filterchain>
            <stripphpcomments />
        </filterchain>
    </reflexive>
</target>
comments powered by Disqus

Info

I'm Ade Slade, a PHP web developer.