forked from zbateson/mail-mime-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
113 lines (102 loc) · 4.55 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
<?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"/>
<property name="release-type" value=""/>
<property name="docs-dir" value="docs"/>
<property name="phpdocs-dir" value="${docs-dir}/phpdocs"/>
<property name="mdapi-dir" value="${docs-dir}/md-api"/>
<property name="wiki-git" value="git@github.com:zbateson/MailMimeParser.wiki.git"/>
<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 ${wiki-git} to ${mdapi-dir}</echo>
<exec executable="git" logoutput="true">
<arg value="clone"/>
<arg value="${wiki-git}"/>
<arg path="${mdapi-dir}"/>
</exec>
</target>
<target name="push-docs" description="Pushes changed documentation to git remote">
<echo>Executing "git add -A" on ${mdapi-dir}</echo>
<exec executable="git" dir="${mdapi-dir}" logoutput="true">
<arg value="add"/>
<arg value="-A"/>
</exec>
<echo>git commit</echo>
<exec executable="git" dir="${mdapi-dir}" logoutput="true">
<arg value="commit"/>
<arg value="-m"/>
<arg value="API update for version: ${version}"/>
</exec>
<echo>git push</echo>
<exec executable="git" dir="${mdapi-dir}" logoutput="true">
<arg value="push"/>
</exec>
</target>
<target name="generate-docs" description="Creates MD-formatted API documentation">
<echo>Generating documentation for ${version}</echo>
<mkdir dir="${phpdocs-dir}"/>
<mkdir dir="${mdapi-dir}"/>
<echo>Calling phpdoc and generating XML in ${phpdocs-dir}</echo>
<exec executable="vendor/bin/phpdoc">
<arg value="-d"/>
<arg path="src"/>
<arg value="-t"/>
<arg path="${phpdocs-dir}"/>
<arg value="--template=xml"/>
</exec>
<echo>Calling phpdocmd and generating MD in ${mdapi-dir}</echo>
<exec executable="vendor/bin/phpdocmd">
<arg value="--lt"/>
<arg value="%c"/>
<arg path="${phpdocs-dir}/structure.xml"/>
<arg path="${mdapi-dir}"/>
</exec>
</target>
<target name="cleanup-docs" description="Deletes documentation directories">
<delete dir="${docs-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"/>
<phingcall target="cleanup-docs"/>
<phingcall target="clone-docs"/>
<phingcall target="generate-docs"/>
<phingcall target="push-docs"/>
<phingcall target="cleanup-docs"/>
</target>
</project>