move "additional options" button in the middle, and make it not so visible
[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.5" />
12   <property name="version"    value="0.5.0" />
13   <property name="stability"  value="beta" />
14   <property name="releasenotes" value="
15 Version 0.5.0 - 2015-01-29
16 --------------------------
17 * Implement paste embedding via JavaScript
18 * Implement paste embedding via oEmbed
19 * Implement single file editing
20 * Implement automatic login
21 * Implement Elasticsearch 1.3 compatibility
22 * Work around PHP bug #68347 to parse ini files correctly
23 * Move clone URLs to sidebar
24 * Move additional button into text field
25 " />
26   <property name="libdir"      value="${phing.dir}/lib"/>
27
28   <property name="zipfile"     value="${phing.project.name}-${version}.tar.bz2" />
29   <property name="pharfile"    value="${phing.project.name}-${version}.phar" />
30   <property name="pkgfile"     value="${phing.project.name}-${version}.tgz" />
31
32   <property name="pharpath"    value="${phing.dir}/dist/${pharfile}" />
33   <property name="distfile"    value="dist/${zipfile}" />
34   <property name="distpkgfile" value="dist/pear/${pkgfile}" />
35
36   <property name="sfproject"   value="phorkie" />
37   <property name="sffilepath"  value="p/ph/phorkie/" />
38
39   <fileset id="fs.zip" dir=".">
40    <include name="data/**"/>
41    <include name="scripts/**"/>
42    <include name="src/**"/>
43    <include name="www/**"/>
44
45    <include name="ChangeLog"/>
46    <include name="LICENSE"/>
47    <include name="NEWS.rst"/>
48    <include name="README.rst"/>
49
50    <exclude name="**/.git/"/>
51    <exclude name="**/.gitignore/"/>
52    <exclude name="data/config.php"/>
53    <exclude name="www/**/.phar"/>
54    <exclude name="www/repos"/>
55   </fileset>
56
57   <fileset id="fs.phar" dir="${phing.dir}">
58    <include name="data/**"/>
59    <include name="lib/**"/>
60    <include name="scripts/**"/>
61    <include name="src/**"/>
62    <include name="www/**"/>
63
64    <include name="ChangeLog"/>
65    <include name="README.rst"/>
66
67    <exclude name="data/config.php"/>
68    <exclude name="**/.git/"/>
69    <exclude name="**/.gitignore/"/>
70    <exclude name="www/**/.phar"/>
71    <exclude name="www/repos"/>
72   </fileset>
73
74   <fileset id="fs.doc" dir=".">
75    <include name="README.rst"/>
76    <include name="NEWS.rst"/>
77   </fileset>
78
79   <taskdef name="d51pearpkg2" classname="phing.tasks.ext.d51PearPkg2Task" />
80
81
82   <target name="phar" depends="preparedirs,collectdeps"
83           description="Create phar file for release"
84   >
85    <delete file="${pharpath}"/>
86    <exec command="php scripts/build-rewritemap.php" dir="${phing.dir}"/>
87    <pharpackage basedir="${phing.dir}"
88                 destfile="${pharpath}"
89                 stub="${phing.dir}/src/stub-phar.php"
90                 alias="phorkie.phar"
91    >
92     <fileset refid="fs.phar"/>
93    </pharpackage>
94
95    <exec executable="bzip2" dir="${phing.dir}/dist">
96     <arg value="-kf"/>
97     <arg file="${pharpath}"/>
98    </exec>
99   </target>
100
101
102   <target name="collectdeps" description="Copy package dependencies to lib/">
103    <delete dir="${libdir}"/>
104    <mkdir dir="${libdir}"/>
105
106    <!-- requires phing >= 2.8.0 -->
107    <copy todir="${libdir}">
108     <pearPackageFileset package="pear.php.net/Cache_Lite"/><!-- OpenID -->
109     <pearPackageFileset package="pear.php.net/Console_Getopt"/>
110     <pearPackageFileset package="pear.php.net/Crypt_DiffieHellman"/><!-- OpenID -->
111     <pearPackageFileset package="pear.php.net/Date_HumanDiff"/>
112     <pearPackageFileset package="pear.geshi.org/geshi">
113      <!-- remove files that are probably not needed to save space in the .phar -->
114      <exclude name="geshi/arm.php"/>
115      <exclude name="geshi/autoit.php"/>
116      <exclude name="geshi/thinbasic.php"/>
117     </pearPackageFileset>
118     <pearPackageFileset package="pear.php.net/HTTP2"/>
119     <pearPackageFileset package="pear.php.net/HTTP_Request2"/>
120     <pearPackageFileset package="pear.php.net/MIME_Type"/>
121     <pearPackageFileset package="zustellzentrum.cweiske.de/MIME_Type_PlainDetect"/>
122     <pearPackageFileset package="zustellzentrum.cweiske.de/MIME_Type_PlainDetect" role="data"/>
123     <pearPackageFileset package="pear.michelf.com/Markdown"/>
124     <pearPackageFileset package="pear.php.net/Net_URL2"/>
125     <pearPackageFileset package="pear.php.net/OpenID"/>
126     <pearPackageFileset package="pear.php.net/Pager"/>
127     <pearPackageFileset package="pear.php.net/PEAR">
128      <include name="PEAR/Exception.php"/>
129      <include name="PEAR.php"/>
130      <include name="PEAR5.php"/>
131      <include name="OS/Guess.php"/>
132      <include name="System.php"/>
133     </pearPackageFileset>
134     <pearPackageFileset package="pear.php.net/Services_Libravatar"/>
135     <pearPackageFileset package="pear2.php.net/PEAR2_Services_Linkback"/>
136     <pearPackageFileset package="pear.php.net/Services_Yadis"/>
137     <pearPackageFileset package="pear.php.net/System_Command"/>
138     <pearPackageFileset package="pear.twig-project.org/Twig"/>
139     <pearPackageFileset package="pear.php.net/Validate"/>
140     <pearPackageFileset package="pear.php.net/VersionControl_Git"/>
141    </copy>
142   </target>
143
144
145   <target name="zip" depends="preparedirs"
146    description="Create zip file for release"
147    >
148     <!--
149       The release file is for end users, so it is safe to
150       remove anything developer-related.
151
152       Test your zip with: unzip -l phorkie-0.1.0.zip
153     -->
154     <echo msg="Creating distribution zip for phorkie ${version}"/>
155     <delete file="${distfile}" failonerror="false"/>
156     <tar compression="bzip2" destfile="${distfile}"
157          prefix="${phing.project.name}-${version}/"
158     >
159      <fileset refid="fs.zip"/>
160     </tar>
161   </target>
162
163
164
165   <target name="pear" depends="check"
166    description="Creates the pear package"
167   >
168    <d51pearpkg2 dir="." baseinstalldir="/">
169      <name>phorkie</name>
170      <summary>Self-hosted pastebin software</summary>
171      <description>
172       Self-hosted pastebin software written in PHP.
173       Pastes are editable, may have multiple files and are stored in git repositories.
174      </description>
175      <channel>phorkie.sourceforge.net</channel>
176
177      <lead user="cweiske" name="Christian Weiske" email="cweiske@cweiske.de" />
178      <license>AGPL</license>
179
180      <version   release="${version}"   api="${version}" />
181      <stability release="${stability}" api="${stability}" />
182
183      <notes>${releasenotes}</notes>
184
185      <dependencies>
186        <php minimum_version="5.3.0" />
187        <pear minimum_version="1.9.0" />
188
189        <package name="Date_HumanDiff"
190                 channel="pear.php.net"
191                 minimum_version="0.4.0"
192                 />
193        <package name="HTTP_Request2"
194                 channel="pear.php.net"
195                 minimum_version="2.1.0"
196                 />
197        <package name="OpenID"
198                 channel="pear.php.net"
199                 minimum_version="0.3.3"
200                 />
201        <package name="Pager"
202                 channel="pear.php.net"
203                 minimum_version="2.4.8"
204                 />
205        <package name="PEAR2_Services_Linkback"
206                 channel="pear2.php.net"
207                 minimum_version="0.2.1"
208                 />
209        <package name="Services_Libravatar"
210                 channel="pear.php.net"
211                 minimum_version="0.2.2"
212                 />
213        <package name="VersionControl_Git"
214                 channel="pear.php.net"
215                 minimum_version="0.4.4"
216                 />
217
218        <package name="geshi"
219                 channel="pear.geshi.org/geshi"
220                 minimum_version="1.0.0"
221                 />
222        <package name="Markdown"
223                 channel="pear.michelf.com"
224                 minimum_version="0.0.2"
225                 />
226        <package name="MIME_Type_PlainDetect"
227                 channel="zustellzentrum.cweiske.de"
228                 minimum_version="0.0.2"
229                 />
230        <package name="Twig"
231                 channel="pear.twig-project.org"
232                 minimum_version="1.6.0"
233                 />
234
235      </dependencies>
236
237      <!-- map directory (key) to role -->
238      <dirroles key="data">data</dirroles>
239      <dirroles key="scripts">data</dirroles>
240      <dirroles key="src">php</dirroles>
241      <dirroles key="www">www</dirroles>
242
243      <!-- do not add the following files to the package.
244           copied from excludes above -->
245      <ignore>**/.gitignore</ignore>
246      <ignore>build*</ignore>
247      <ignore>data/config.php</ignore>
248      <ignore>dist/**</ignore>
249      <ignore>*.properties</ignore>
250      <ignore>*.tgz</ignore>
251
252      <replacement path="www/www-header.php"
253       type="pear-config" from="@data_dir@" to="data_dir"
254       />
255
256
257    </d51pearpkg2>
258
259    <!-- time to fix the package.xml file since the task does not
260         allow everything we need:
261         - strip the base directory names like src, data and www
262         - remove that dumb baseinstalldir from files
263         - md5sums are generated automatically when packaging
264    -->
265    <!-- yes, we need to generate a 2nd file and move it back -->
266    <copy file="package.xml" tofile="package2.xml" overwrite="true">
267     <filterchain>
268      <replaceregexp>
269       <!-- remove md5sums -->
270       <regexp
271        pattern="md5sum=&quot;[a-z0-9]{32}&quot; "
272        replace=""
273        />
274       <!-- remove baseinstalldir for files -->
275       <regexp
276        pattern="&lt;file baseinstalldir=&quot;/&quot;"
277        replace="&lt;file"
278        />
279       <!-- install-as for different directories -->
280       <regexp
281        pattern="(&lt;file name=&quot;data/(.+?)&quot;)"
282        replace="\1 install-as=&quot;\2&quot;"
283        />
284       <regexp
285        pattern="(&lt;file name=&quot;doc/(.+?)&quot;)"
286        replace="\1 install-as=&quot;\2&quot;"
287        />
288       <regexp
289        pattern="(&lt;file name=&quot;tests/(.+?)&quot;)"
290        replace="\1 install-as=&quot;\2&quot;"
291        />
292       <regexp
293        pattern="(&lt;file name=&quot;www/(.+?)&quot;)"
294        replace="\1 install-as=&quot;phorkie/\2&quot;"
295        />
296       <regexp
297        pattern="(&lt;file name=&quot;src/(.+?)&quot;)"
298        replace="\1 install-as=&quot;\2&quot;"
299        />
300      </replaceregexp>
301     </filterchain>
302    </copy>
303    <move file="package2.xml" tofile="package.xml" overwrite="true" />
304
305    <!-- package up -->
306    <exec command="pear package" passthru="true" />
307    <move file="${pkgfile}" todir="dist/pear/" />
308
309    <delete file="package.xml" failonerror="true" />
310   </target>
311
312
313   <target name="build-docs" description="render documentation">
314    <rST format="html" uptodate="true">
315     <fileset refid="fs.doc"/>
316     <mapper type="regexp" from="^(.+?).rst$" to="dist/docs/\1.html"/>
317    </rST>
318   </target>
319
320   <target name="clean-docs" description="delete rendered documentation files">
321    <delete dir="dist/docs" includeemptydirs="yes"/>
322   </target>
323
324
325   <target name="release" depends="check,zip,pear,deploy-sf"
326    description="Release the version on sourceforge"
327    >
328    <!-- meta-target -->
329   </target>
330
331
332   <!--
333   /home/frs/project/p/ph/phorkie/phorkie/v0.1/
334   /home/frs/project/p/ph/phorkie/phorkie/v0.1/phorkie-v0.1.0.zip
335   /home/frs/project/p/ph/phorkie/phorkie/v0.1/phorkie-v0.1.1.zip
336   https://sourceforge.net/apps/trac/sourceforge/wiki/Release%20files%20for%20download
337   -->
338   <target name="deploy-sf" depends="check,zip,phar"
339    description="Upload release to sourceforge"
340    >
341     <delete dir="dist/deploy-sf" /><!-- make empty -->
342     <mkdir dir="dist/deploy-sf" />
343     <mkdir dir="dist/deploy-sf/v${version-m}" />
344     <copy file="${distfile}" tofile="dist/deploy-sf/v${version-m}/${zipfile}"/>
345     <copy file="${pharpath}" tofile="dist/deploy-sf/v${version-m}/${pharfile}"/>
346     <!-- test
347     <exec command="rsync -av dist/deploy-sf/ /tmp/test/" escape="false" />
348     -->
349     <exec
350      command="rsync -av -e ssh dist/deploy-sf/ ${sfuser},${sfproject}@frs.sourceforge.net:/home/frs/project/${sffilepath}/${sfproject}/"
351      escape="false" checkreturn="false"
352      />
353     <!-- rsync always returns code 23 on sourceforge releases, so we
354          can't check return values -->
355   </target>
356
357
358   <target name="preparedirs">
359     <mkdir dir="dist" />
360   </target>
361
362   <target name="check" depends="preparedirs"
363    description="Check variables"
364    >
365     <fail unless="version" message="Version not defined!" />
366     <fail unless="sfuser" message="Sourceforge username not defined!" />
367     <fail unless="sfproject" message="Sourceforge project name not defined!" />
368     <fail unless="sffilepath" message="Sourceforge project file path not defined!" />
369   </target>
370
371 </project>