-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
168 lines (152 loc) · 5.75 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<project name="XH" default="package">
<!-- version 7.1 -->
<tstamp/>
<property file="build.properties"/>
<property environment="env"/>
<property name="env.BUILD_NUMBER" value=""/>
<property name="build.number" value=""/>
<property name="addon.dir" location="${ADDONLOC}/${ant.project.name}"/>
<!-- Pull git repo info -->
<!-- Get the last tag reachable from this branch -->
<exec executable="git" dir="." outputproperty="git.tag" failifexecutionfails="false" errorproperty="">
<arg line="describe --tags --abbrev=0" />
</exec>
<!-- Get a 'revision' based on last tag, commit count, commitsha, and branch name -->
<exec executable="git" dir="." outputproperty="git.revision" failifexecutionfails="false" errorproperty="">
<arg line="describe --tags --always HEAD" />
</exec>
<condition property="repository.version" value="${git.revision}" else="unknown">
<and>
<isset property="git.revision"/>
<length string="${git.revision}" trim="yes" length="0" when="greater"/>
</and>
</condition>
<!-- find gitbranch -->
<!-- find gitbranch -->
<exec executable="git" dir="." outputproperty="git.branch.tmp" failifexecutionfails="false" errorproperty="">
<arg line="rev-parse --abbrev-ref HEAD"/>
</exec>
<!-- replace '/' in branch name with '_' -->
<loadresource property="git.branch">
<propertyresource name="git.branch.tmp"/>
<filterchain>
<tokenfilter>
<replacestring from="/" to="_"/>
</tokenfilter>
</filterchain>
</loadresource>
<!-- assign the git.branch to the branch property -->
<condition property="branch" value="-${git.branch}" else="">
<and>
<isset property="git.branch"/>
<not>
<or>
<equals arg1="${git.branch}" arg2="master"/>
<equals arg1="${git.branch}" arg2="HEAD"/>
</or>
</not>
</and>
</condition>
<property name="version.number" value="${repository.version}${branch}${build.number}"/>
<echo>Building: ${version.number}</echo>
<!-- end git repo info -->
<property name="project.zip" value="${ant.project.name}_${version.number}.zip"/>
<property name="test.dir" location="test"/>
<property name="target.dir" location="target"/>
<property name="working.dir" location="${target.dir}/working"/>
<property name="report.dir" location="${target.dir}/reports"/>
<condition property="test.check">
<available file="${test.dir}/test.lua" type="file"/>
</condition>
<filter token="VERSION" value="${version.number}"/>
<filter token="INTERFACE" value="${INTERFACE}"/>
<patternset id="packageFiles">
<include name="src/*.xml"/>
<include name="src/*.toc"/>
<include name="src/*.lua"/>
<include name="src/Readme.txt"/>
<include name="src/HowTo.md"/>
<include name="${working.dir}/*.txt"/>
</patternset>
<!-- -->
<target name="clean" description="Cleans old builds">
<delete dir="target" verbose="true"/>
</target>
<target name="changelog" description="Creates a changelog">
<mkdir dir="${working.dir}"/>
<echo file="${working.dir}/changelog.txt">Changes since ${git.tag}..${line.separator}${line.separator}</echo>
<exec executable="git" dir=".">
<arg line="log --graph --pretty=format:'%h %ci - %d %s <%an>' ${git.tag}~1.."/>
<redirector append="true" output="${working.dir}/changelog.txt"/>
</exec>
</target>
<target name="package" depends="changelog, test" description="Create a deploy package">
<property name="package.dir" location="${working.dir}/${ant.project.name}"/>
<delete dir="${package.dir}" verbose="false"/>
<copy todir="${package.dir}" filtering="true" flatten="true">
<fileset dir=".">
<patternset refid="packageFiles"/>
</fileset>
</copy>
<zip destfile="${target.dir}/${project.zip}"
basedir="${working.dir}"
includes="${ant.project.name}/**"/>
<checksum file="${target.dir}/${project.zip}"
property="zip.md5" />
<echo file="${target.dir}/${project.zip}.md5">${zip.md5} ${project.zip}${line.separator}</echo>
</target>
<target name="web.deploy" description="deploys the web site">
<mkdir dir="${target.dir}/web"/>
<zip destfile="${target.dir}/${ant.project.name}-web.zip"
basedir="src/web"
includes="**"/>
<exec executable="rsync" dir="src/web" failonerror="true">
<arg line='-rvihz --rsh="/usr/bin/ssh -l ${USER} -p 2022" . ${USER}@${HOST}:${DIR}'/>
</exec>
<!-- <delete dir="${target.dir}/web" verbose="true"/> -->
</target>
<target name="wow" depends="test" description="copy files to currnet wow install">
<mkdir dir="${addon.dir}"/>
<delete>
<fileset dir="${addon.dir}" includes="*.toc"/>
</delete>
<copy todir="${addon.dir}" filtering="true" verbose="true">
<fileset dir="src">
<include name="*.lua"/>
<include name="*.toc"/>
<include name="*.xml"/>
<include name="Readme.txt"/>
<include name="HowTo.md"/>
</fileset>
</copy>
<echo>Deployed ${version.number} locally</echo>
</target>
<target name="open" description="open the addon dir in the current wow install">
<exec executable="open">
<arg value="${addon.dir}"/>
</exec>
</target>
<target name="test" description="run unit tests" if="test.check">
<mkdir dir="${report.dir}"/>
<exec executable="lua" dir="test" resultproperty="testResult">
<arg value="test.lua"/>
</exec>
<move todir="${report.dir}" file="${test.dir}/testOut.xml"/>
<fail message="The tests failed. Please see the output for details." status="${testResult}">
<condition>
<not>
<equals arg1="${testResult}" arg2="0"/>
</not>
</condition>
</fail>
</target>
<target name="curse" depends="package" description="Copy files to the local curseforge path">
<property name="curse.dir" location="${ant.project.name}-cf"/>
<copy todir="${curse.dir}">
<fileset dir="${package.dir}"/>
</copy>
<exec executable="git" dir="${curse.dir}" failifexecutionfails="true" errorproperty="">
<arg line="status" />
</exec>
</target>
</project>