forked from zbateson/mail-mime-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
121 lines (107 loc) · 4.93 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?xml version="1.0" encoding="UTF-8"?>
<project name="MailMimeParser" default="nothing">
<property name="version-file" value="version.txt"/>
<loadfile property="version" file="version.txt"/>
<propertyregex property="api-version" subject="${version}"
pattern="^\d+\.\d+" match="$0" defaultValue="0.0.1"/>
<property name="release-type" value=""/>
<property name="clone-dir" value="/tmp/mmp"/>
<property name="api-dir" value="${clone-dir}/api/${api-version}"/>
<property name="api-git" value="[email protected]:zbateson/mail-mime-parser.git"/>
<property name="api-branch" value="gh-pages"/>
<target name="nothing" hidden="true">
<echo>
Used for creating a release. Default target does nothing.
Call phing with "-l" to see available targets.
</echo>
</target>
<target name="clone-docs" description="Clones documentation from remote">
<echo>Cloning ${api-git} to ${clone-dir}</echo>
<exec executable="git" logoutput="true">
<arg value="clone"/>
<arg value="-b"/>
<arg value="${api-branch}"/>
<arg value="${api-git}"/>
<arg value="--depth"/>
<arg value="1"/>
<arg path="${clone-dir}"/>
</exec>
</target>
<target name="push-docs" description="Pushes changed documentation to git remote">
<echo>Executing "git add -A" on ${clone-dir}</echo>
<exec executable="git" dir="${clone-dir}" logoutput="true">
<arg value="add"/>
<arg value="-A"/>
</exec>
<echo>git commit</echo>
<exec executable="git" dir="${clone-dir}" logoutput="true">
<arg value="commit"/>
<arg value="-m"/>
<arg value="phpdoc generation for version: ${version}"/>
</exec>
<echo>git push</echo>
<exec executable="git" dir="${clone-dir}" logoutput="true">
<arg value="push"/>
</exec>
</target>
<target name="generate-docs" description="Generates phpdoc API documentation">
<echo>Generating documentation for ${version}</echo>
<delete dir="${api-dir}" quiet="true"/>
<mkdir dir="${api-dir}"/>
<echo>Calling phpdoc and generating XML in ${api-dir}</echo>
<exec executable="phpdoc" passthru="true" logoutput="true" checkreturn="true">
<arg value="run"/>
<arg value="-d"/>
<arg path="${project.basedir}/src"/>
<arg value="-t"/>
<arg path="${api-dir}"/>
<arg value="--defaultpackagename=MailMimeParser"/>
<arg value="--title=MailMimeParser ${api-version}"/>
</exec>
</target>
<target name="cleanup-docs" description="Deletes documentation directories">
<delete dir="${clone-dir}" quiet="true"/>
</target>
<target name="release" description="Bumps the version number, then updates documentation">
<!--
The following IfTask must be kept inside 'release'. Using phingcall and setting a property
inside a different target sets the property within that target's scope only.
-->
<if>
<equals arg1="${release-type}" arg2=""/>
<then>
<property name="release-type" value="Bugfix" override="true"/>
<echo>Enter a release type (1 to 3) or default to 3.</echo>
<echo>1. Major</echo>
<echo>2. Minor</echo>
<echo>3. Bugfix</echo>
<input propertyname="release-type-index" defaultValue="3" promptChar=":"> Enter</input>
<if>
<equals arg1="${release-type-index}" arg2="1"/>
<then>
<echo>Setting from ${release-type} to Major, no?</echo>
<property name="release-type" value="Major" override="true"/>
<echo>Now it is ${release-type}</echo>
</then>
<elseif>
<equals arg1="${release-type-index}" arg2="2"/>
<then>
<property name="release-type" value="Minor" override="true"/>
</then>
</elseif>
</if>
</then>
</if>
<echo>${release-type} Release - incrememting version number</echo>
<version releasetype="${release-type}" file="version.txt" property="version"/>
<propertyregex property="api-version" subject="${version}"
pattern="^\d+\.\d+" match="$0" defaultValue="0.0.1"
override="true"/>
<property name="api-dir" value="${clone-dir}/api/${api-version}" override="true"/>
<phingcall target="cleanup-docs"/>
<phingcall target="clone-docs"/>
<phingcall target="generate-docs"/>
<phingcall target="push-docs"/>
<phingcall target="cleanup-docs"/>
</target>
</project>