prepare build file for 0.2.0
[phorkie.git] / build.xml
1 <?xml version="1.0" encoding="utf-8"?>
2 <project name="phorkie" default="zip" basedir=".">
3   <!--
4     phorkie phing build file.
5     This script should provide a one-stop tool for all administrative
6     tasks around phorkie, like creating a release version,
7     tagging a release
8   -->
9   <property file="build.properties" />
10
11   <property name="version-m"  value="0.2" />
12   <property name="version"    value="0.2.0" />
13   <property name="stability"  value="alpha" />
14   <property name="releasenotes" value="
15 First release
16 " />
17   <property name="zipfile"     value="${phing.project.name}-${version}.zip" />
18   <property name="pkgfile"     value="${phing.project.name}-${version}.tgz" />
19   <property name="distfile"    value="dist/${zipfile}" />
20   <property name="distpkgfile" value="dist/pear/${pkgfile}" />
21   <property name="sfproject"   value="phorkie" />
22   <property name="sffilepath"  value="p/ph/phorkie/" />
23
24   <fileset id="fs.zip" dir=".">
25    <include name="data/**"/>
26    <include name="src/**"/>
27    <include name="www/**"/>
28    <include name="LICENSE"/>
29    <include name="README.rst"/>
30    <exclude name="**/.gitignore/"/>
31    <exclude name="data/config.php"/>
32   </fileset>
33
34   <fileset id="fs.doc" dir=".">
35    <include name="README.rst"/>
36   </fileset>
37
38   <taskdef name="rST" classname="phing.tasks.ext.rSTTask" />
39   <taskdef name="d51pearpkg2" classname="phing.tasks.ext.d51PearPkg2Task" />
40
41   <target name="zip" depends="check"
42    description="Create zip file for release"
43    >
44     <!--
45       The release file is for end users, so it is safe to
46       remove anything developer-related.
47
48       Test your zip with: unzip -l phorkie-0.1.0.zip
49     -->
50     <echo msg="Creating distribution zip for phorkie ${version}"/>
51     <delete file="${distfile}" failonerror="false"/>
52     <zip destfile="${distfile}" prefix="${phing.project.name}-${version}/">
53      <fileset refid="fs.zip"/>
54     </zip>
55   </target>
56
57
58
59   <target name="package" depends="check"
60    description="Creates the pear package"
61   >
62    <d51pearpkg2 dir="." baseinstalldir="/">
63      <name>phorkie</name>
64      <summary>Self-hosted pastebin software</summary>
65      <description>
66       Self-hosted pastebin software written in PHP.
67       Pastes are editable, may have multiple files and are stored in git repositories.
68      </description>
69      <channel>phorkie.sourceforge.net</channel>
70
71      <lead user="cweiske" name="Christian Weiske" email="cweiske@cweiske.de" />
72      <license>AGPL</license>
73
74      <version   release="${version}"   api="${version}" />
75      <stability release="${stability}" api="${stability}" />
76
77      <notes>${releasenotes}</notes>
78
79      <dependencies>
80        <php minimum_version="5.2.0" />
81        <pear minimum_version="1.9.0" />
82
83        <package name="Date_HumanDiff"
84                 channel="pear.php.net"
85                 minimum_version="0.1.0"
86                 />
87        <package name="HTTP_Request2"
88                 channel="pear.php.net"
89                 minimum_version="2.1.0"
90                 />
91        <package name="Pager"
92                 channel="pear.php.net"
93                 minimum_version="2.4.8"
94                 />
95        <package name="Services_Libravatar"
96                 channel="pear.php.net"
97                 minimum_version="0.2.1"
98                 />
99        <package name="VersionControl_Git"
100                 channel="pear.php.net"
101                 minimum_version="0.4.4"
102                 />
103        <package name="geshi"
104                 channel="mediawiki.googlecode.com/svn"
105                 minimum_version="1.0.0"
106                 />
107        <package name="Twig"
108                 channel="pear.twig-project.org"
109                 minimum_version="1.6.0"
110                 />
111
112      </dependencies>
113
114      <!-- map directory (key) to role -->
115      <dirroles key="www">www</dirroles>
116      <dirroles key="data">data</dirroles>
117      <dirroles key="src">php</dirroles>
118
119      <!-- do not add the following files to the package.
120           copied from excludes above -->
121      <ignore>**/.gitignore</ignore>
122      <ignore>**/.svn</ignore>
123      <ignore>build*</ignore>
124      <ignore>data/config.php</ignore>
125      <ignore>dist/**</ignore>
126      <ignore>*.properties</ignore>
127      <ignore>*.tgz</ignore>
128
129      <replacement path="www/www-header.php"
130       type="pear-config" from="@data_dir@" to="data_dir"
131       />
132
133
134    </d51pearpkg2>
135
136    <!-- time to fix the package.xml file since the task does not
137         allow everything we need:
138         - strip the base directory names like src, data and www
139         - remove that dumb baseinstalldir from files
140         - md5sums are generated automatically when packaging
141    -->
142    <!-- yes, we need to generate a 2nd file and move it back -->
143    <copy file="package.xml" tofile="package2.xml" overwrite="true">
144     <filterchain>
145      <replaceregexp>
146       <!-- remove md5sums -->
147       <regexp
148        pattern="md5sum=&quot;[a-z0-9]{32}&quot; "
149        replace=""
150        />
151       <!-- remove baseinstalldir for files -->
152       <regexp
153        pattern="&lt;file baseinstalldir=&quot;/&quot;"
154        replace="&lt;file"
155        />
156       <!-- install-as for different directories -->
157       <regexp
158        pattern="(&lt;file name=&quot;data/(.+?)&quot;)"
159        replace="\1 install-as=&quot;\2&quot;"
160        />
161       <regexp
162        pattern="(&lt;file name=&quot;doc/(.+?)&quot;)"
163        replace="\1 install-as=&quot;\2&quot;"
164        />
165       <regexp
166        pattern="(&lt;file name=&quot;tests/(.+?)&quot;)"
167        replace="\1 install-as=&quot;\2&quot;"
168        />
169       <regexp
170        pattern="(&lt;file name=&quot;www/(.+?)&quot;)"
171        replace="\1 install-as=&quot;phorkie/\2&quot;"
172        />
173       <regexp
174        pattern="(&lt;file name=&quot;src/(.+?)&quot;)"
175        replace="\1 install-as=&quot;\2&quot;"
176        />
177      </replaceregexp>
178     </filterchain>
179    </copy>
180    <move file="package2.xml" tofile="package.xml" overwrite="true" />
181
182    <!-- package up -->
183    <exec command="pear package" passthru="true" />
184    <move file="${pkgfile}" todir="dist/pear/" />
185
186    <delete file="package.xml" failonerror="true" />
187   </target>
188
189
190   <target name="build-docs" description="render documentation">
191    <rST format="html" uptodate="true">
192     <fileset refid="fs.doc"/>
193     <mapper type="regexp" from="^(.+?).rst$" to="dist/docs/\1.html"/>
194    </rST>
195   </target>
196
197   <target name="clean-docs" description="delete rendered documentation files">
198    <delete dir="dist/docs" includeemptydirs="yes"/>
199   </target>
200
201
202   <target name="release" depends="check,zip,package,deploy-sf"
203    description="Release the version on sourceforge"
204    >
205    <!-- meta-target -->
206   </target>
207
208
209   <!--
210   /home/frs/project/p/ph/phorkie/phorkie/v0.1/
211   /home/frs/project/p/ph/phorkie/phorkie/v0.1/phorkie-v0.1.0.zip
212   /home/frs/project/p/ph/phorkie/phorkie/v0.1/phorkie-v0.1.1.zip
213   https://sourceforge.net/apps/trac/sourceforge/wiki/Release%20files%20for%20download
214   -->
215   <target name="deploy-sf" depends="check,zip"
216    description="Upload release to sourceforge"
217    >
218     <delete dir="dist/deploy-sf" /><!-- make empty -->
219     <mkdir dir="dist/deploy-sf" />
220     <mkdir dir="dist/deploy-sf/v${version-m}" />
221     <copy file="${distfile}" tofile="dist/deploy-sf/v${version-m}/${zipfile}"/>
222     <!-- test
223     <exec command="rsync -av dist/deploy-sf/ /tmp/test/" escape="false" />
224     -->
225     <exec
226      command="rsync -av -e ssh dist/deploy-sf/ ${sfuser},${sfproject}@frs.sourceforge.net:/home/frs/project/${sffilepath}/${sfproject}/"
227      escape="false" checkreturn="false"
228      />
229     <!-- rsync always returns code 23 on sourceforge releases, so we
230          can't check return values -->
231   </target>
232
233
234   <target name="check"
235    description="Check variables"
236    >
237     <fail unless="version" message="Version not defined!" />
238     <fail unless="sfuser" message="Sourceforge username not defined!" />
239     <fail unless="sfproject" message="Sourceforge project name not defined!" />
240     <fail unless="sffilepath" message="Sourceforge project file path not defined!" />
241
242     <mkdir dir="dist" />
243   </target>
244
245 </project>