phing build file to create and deploy releases
[surrogator.git] / build.xml
1 <?xml version="1.0" encoding="utf-8"?>
2 <project name="surrogator" default="zip" basedir=".">
3   <!--
4     surrogator phing build file.
5     This script should provide a one-stop tool for all administrative
6     tasks around surrogator, like creating a release version,
7     tagging a release
8   -->
9   <property file="build.properties" />
10
11   <property name="version-m"  value="0.1" />
12   <property name="version"    value="0.1.0" />
13   <property name="stability"  value="alpha" />
14   <property name="zipfile"     value="${phing.project.name}-${version}.tar.bz2" />
15   <property name="distfile"    value="dist/${zipfile}" />
16   <property name="sfproject"   value="surrogator" />
17   <property name="sffilepath"  value="s/su/surrogator/" />
18
19   <fileset id="fs.zip" dir=".">
20    <include name="data/surrogator.config.php.dist"/>
21    <include name="res/**"/>
22    <include name="www/avatar.php"/>
23    <include name="surrogator.php"/>
24    <include name="ChangeLog"/>
25    <include name="LICENSE"/>
26    <include name="README.rst"/>
27    <exclude name="**/.gitignore"/>
28   </fileset>
29
30   <target name="zip" depends="check"
31    description="Create zip file for release"
32    >
33     <!--
34       The release file is for end users, so it is safe to
35       remove anything developer-related.
36
37       Test your bz2 with: tar -jtvf surrogator-0.1.0.tar.bz2
38     -->
39     <echo msg="Creating distribution zip for ${phing.project.name} ${version}"/>
40     <delete file="${distfile}" failonerror="false"/>
41     <tar compression="bzip2" destfile="${distfile}"
42          prefix="${phing.project.name}-${version}/"
43     >
44      <fileset refid="fs.zip"/>
45     </tar>
46   </target>
47
48
49   <target name="release" depends="check,zip,deploy-sf"
50    description="Release the version on sourceforge"
51    >
52    <!-- meta-target -->
53   </target>
54
55
56   <!--
57   /home/frs/project/s/su/surrogator/v0.1/
58   /home/frs/project/s/su/surrogator/v0.1/surrogator-v0.1.0.zip
59   /home/frs/project/s/su/surrogator/v0.1/surrogator-v0.1.1.zip
60   https://sourceforge.net/apps/trac/sourceforge/wiki/Release%20files%20for%20download
61   -->
62   <target name="deploy-sf" depends="check,zip"
63    description="Upload release to sourceforge"
64    >
65     <delete dir="dist/deploy-sf" /><!-- make empty -->
66     <mkdir dir="dist/deploy-sf" />
67     <mkdir dir="dist/deploy-sf/v${version-m}" />
68     <copy file="${distfile}" tofile="dist/deploy-sf/v${version-m}/${zipfile}"/>
69     <!-- test
70     <exec command="rsync -av dist/deploy-sf/ /tmp/test/" escape="false" />
71     -->
72     <exec
73      command="rsync -av -e ssh dist/deploy-sf/ ${sfuser},${sfproject}@frs.sourceforge.net:/home/frs/project/${sffilepath}/"
74      escape="false" checkreturn="false"
75      />
76     <!-- rsync always returns code 23 on sourceforge releases, so we
77          can't check return values -->
78   </target>
79
80
81   <target name="check"
82    description="Check variables"
83    >
84     <fail unless="version" message="Version not defined!" />
85     <fail unless="sfuser" message="Sourceforge username not defined!" />
86     <fail unless="sfproject" message="Sourceforge project name not defined!" />
87     <fail unless="sffilepath" message="Sourceforge project file path not defined!" />
88
89     <mkdir dir="dist" />
90   </target>
91
92 </project>