-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.xml
292 lines (242 loc) · 12 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<?xml version="1.0" encoding="UTF-8"?>
<project name="buildtools" phingVersion="2.4.5" default="help">
<includepath classpath="./buildtools" />
<!-- Load in the custom tasks -->
<taskdef name="findRepos" classname="src.FindRepositoriesTask" />
<taskdef name="sschangelog" classname="src.CreateChangelog" />
<taskdef name="generateJavascriptI18nTask" classname="src.GenerateJavascriptI18nTask" />
<property name="basedir" value="." override="true" />
<property name="archiveDest" value="." />
<property name="frameworkdir" value="framework" />
<property name="modules" value="${frameworkdir},cms,reports,siteconfig" />
<property name="modulesAndRoot" value=".,${modules}" />
<property name="changelog.toCommit" value="refs/heads/${baseBranchName}" />
<!--
=================================================================
Helper Targets
=================================================================
-->
<target name="help">
<echo>
SilverStripe Project Build
------------------------------------
This build file contains targets to assist in creating new SilverStripe builds and releases.
Run "phing -l" to get a full list of available targets.
Options:
-Dbasedir = . (the base directory to operate on)
-Dmodule (the name of the module directory used in various tasks)
-DarchiveName (the name of the created archive file)
-DarchiveDest (the destination directory to put the archive)
-DtagName (the name of the tag/branch to check out or to create as a new tag)
</echo>
</target>
<target name="release"
description="Wrapper task to handle a release"
depends="changelog,tag,archive,upload">
<echo msg="### Done! Please do the following manually:" />
<echo msg=" * Release announcement on mailinglist and forum" />
<echo msg=" * Update silverstripe.org download links" />
<echo msg=" * Close milestones in the issue tracker" />
<echo msg=" * ... and more. See http://goo.gl/68pXb for instructions." />
</target>
<target name="setup">
<propertyprompt propertyName="confirmNoLocalChanges"
promptText="This should be a fresh installation created through 'composer create-project'. It should NOT have local changes, local commits or unversioned files. Confirm?" />
<propertyprompt propertyName="baseBranchName"
promptText="Base branch name?"
useExistingValue="true"
defaultValue="x.y" />
<propertyprompt propertyName="tagName"
promptText="Tag name? Check http://goo.gl/1EDBJ for conventions"
useExistingValue="true"
defaultValue="x.y.z[-(alpha|beta|rc)]" />
<php expression="version_compare(preg_replace('/([\d\.]*)(.*)/', '$1', '${tagName}'), '3.0', '<=')" returnProperty="versionLowerThan3x" />
<echo msg="### Checking out ${baseBranchName}" />
<property name="branchName" value="${baseBranchName}" override="true" />
</target>
<target name="tag"
description="Tag each module and push tags"
depends="setup">
<echo msg="### Creating tags" />
<foreach list="${modules},." param="module" target="module-create-tag" />
<foreach list="${modules},." param="module" target="module-push-tag" />
</target>
<target name="module-create-tag" if="basedir,module,tagName"
description="Creates a new git tag in the chosen repo">
<!-- TODO Prompt for overwriting existing tag -->
<!-- Force commit to ensure packagist release date is accurate -->
<gittag repository="${module}" name="${tagName}" force="true" annotate="true" message="Tagged ${tagName}" />
<echo msg="git tag '${tagName}' added to '${module}' git repository" />
</target>
<target name="module-push-tag" if="basedir,module,tagName"
description="Pushes all local tags to their respective origin repositories">
<gitpush refspec="refs/heads/${baseBranchName}" repository="${module}" />
<gitpush refspec="refs/tags/${tagName}" force="true" repository="${module}" />
<echo msg="Pushed tags for '${module}'" />
</target>
<target name="archive" if="tagName"
description="Creates a gzip archive from the current folder (removes any version control files)">
<php function="sys_get_temp_dir" returnProperty="systmp" />
<property name="archiveName" value="SilverStripe-cms-v${tagName}" />
<property name="frameworkArchiveName" value="SilverStripe-framework-v${tagName}" />
<property name="tmp" value="${systmp}/archiveTask" />
<php expression="version_compare(preg_replace('/([\d\.]*)(.*)/', '$1', '${tagName}'), '3.0', '<=')" returnProperty="versionLowerThan3x" />
<delete dir="${tmp}" failonerror="false" quiet="true" />
<mkdir dir="${tmp}" />
<echo msg="### Creating '${archiveName}' archive" />
<httpget url="http://getcomposer.org/composer.phar" dir="${tmp}" />
<exec command="php composer.phar create-project silverstripe/installer ${archiveName} ${tagName} --prefer-dist --no-dev"
dir="${tmp}" checkreturn="true" logoutput="true" />
<!-- Copy composer.phar into the archive -->
<copy file="${tmp}/composer.phar" tofile="${tmp}/${archiveName}/composer.phar" />
<!-- Write version info to the core folders (shouldn't be in version control) -->
<echo msg="${tagName}" file="${tmp}/${archiveName}/${frameworkdir}/silverstripe_version" />
<echo msg="${tagName}" file="${tmp}/${archiveName}/cms/silverstripe_version" />
<!-- remove development files not needed in the archive package -->
<delete failonerror="false" quiet="true">
<fileset dir="${tmp}/${archiveName}">
<include name="**/docs/**" />
<include name="**/tests/**" />
<include name="build.xml" />
<include name="behat.yml" />
<include name="phpunit.*" />
</fileset>
</delete>
<!-- remove any pre-existing archives -->
<delete failonerror="false" quiet="true">
<fileset dir="${archiveDest}">
<include name="${archiveName}.tar.gz" />
<include name="${archiveName}.zip" />
</fileset>
</delete>
<!-- create tar archive - CMS -->
<tar destfile="${archiveDest}/${archiveName}.tar.gz" compression="gzip">
<fileset dir="${tmp}/${archiveName}">
<include name="**" />
</fileset>
</tar>
<echo msg="Created archive: ${archiveDest}/${archiveName}-cms-v${tagName}.tar.gz" />
<echo msg="##teamcity[publishArtifacts '${archiveName}-cms-v${tagName}.tar.gz']" />
<!-- create zip archive - CMS -->
<zip destfile="${archiveDest}/${archiveName}.zip">
<fileset dir="${tmp}/${archiveName}">
<include name="**" />
</fileset>
</zip>
<echo msg="Created archive: ${archiveDest}/${archiveName}-cms-v${tagName}.zip" />
<echo msg="##teamcity[publishArtifacts '${archiveName}-cms-v${tagName}.zip']" />
<if>
<not><istrue value="${versionLowerThan3x}" /></not>
<then>
<exec command="php composer.phar remove silverstripe/cms silverstripe/siteconfig --update-no-dev"
dir="${tmp}/${archiveName}"
checkreturn="true" logoutput="true" />
<!-- remove any pre-existing archives -->
<delete file="${archiveDest}/${frameworkArchiveName}.tar.gz" failonerror="false" quiet="true" />
<delete file="${archiveDest}/${frameworkArchiveName}.zip" failonerror="false" quiet="true" />
<!-- create tar archive - Framework -->
<tar destfile="${archiveDest}/${frameworkArchiveName}.tar.gz" compression="gzip">
<fileset dir="${tmp}/${archiveName}">
<include name="**" />
</fileset>
</tar>
<!-- create zip archive - Framework -->
<zip destfile="${archiveDest}/${frameworkArchiveName}.zip">
<fileset dir="${tmp}/${archiveName}">
<include name="**" />
</fileset>
</zip>
<echo msg="Created archive: ${archiveDest}/${frameworkArchiveName}.tar.gz" />
<echo msg="##teamcity[publishArtifacts '${frameworkArchiveName}.tar.gz']" />
<echo msg="Created archive: ${archiveDest}/${frameworkArchiveName}.zip" />
<echo msg="##teamcity[publishArtifacts '${frameworkArchiveName}.zip']" />
</then>
</if>
<!-- clear the temp file -->
<delete dir="${tmp}" failonerror="false" quiet="true" />
</target>
<target name="upload"
description="Uploads archives previously created through 'ping archive' to a public webhost, and notifies a group of people of the new release. Requires working public key auth on the release destination."
depends="setup,archive"
if="tagName">
<echo msg="### Uploading archive" />
<propertyprompt propertyName="confirmUpload"
promptText="Please unzip and sanity check the created archives. Ready for upload?" />
<property name="release_dest" value="[email protected]:/var/www/mysite/shared/assets/releases" />
<property name="release_url" value="http://silverstripe.org/assets/releases/" />
<if>
<istrue value="${versionLowerThan3x}" />
<then>
<exec command="scp -P 2222 SilverStripe-cms-v${tagName}.tar.gz SilverStripe-cms-v${tagName}.zip ${release_dest}" checkreturn="true" logoutput="true" />
<echo>
Successfully uploaded to:
${release_url}SilverStripe-cms-v${tagName}.tar.gz
${release_url}SilverStripe-cms-v${tagName}.zip
</echo>
</then>
<else>
<exec command="scp -P 2222 SilverStripe-cms-v${tagName}.tar.gz SilverStripe-framework-v${tagName}.tar.gz SilverStripe-cms-v${tagName}.zip SilverStripe-framework-v${tagName}.zip ${release_dest}" checkreturn="true" logoutput="true" />
<echo>
Successfully uploaded to:
${release_url}SilverStripe-cms-v${tagName}.tar.gz
${release_url}SilverStripe-framework-v${tagName}.tar.gz
${release_url}SilverStripe-cms-v${tagName}.zip
${release_url}SilverStripe-framework-v${tagName}.zip
</echo>
</else>
</if>
</target>
<target name="changelog"
description="Create a changelog.md file collated from multiple repos"
if="basedir"
depends="setup">
<echo msg="### Creating changelog" />
<propertyprompt propertyName="changelog.fromCommit"
promptText="Create changelog from which tag/branch/commit? (use refs/heads/branchname or refs/tags/tagname to qualify branches or tags)"
useExistingValue="true" />
<propertyprompt propertyName="changelog.toCommit"
promptText="Create changelog to which tag/branch/commit? (use refs/heads/branchname or refs/tags/tagname to qualify branches or tags)"
useExistingValue="true" />
<propertyprompt propertyName="tagName"
promptText="Tag name?"
useExistingValue="true" />
<sschangelog fromCommit="${changelog.fromCommit}" toCommit="${changelog.toCommit}" paths="${modules}" baseDir="${basedir}" />
<if>
<contains string="${changelog.toCommit}" substring="alpha" />
<then><property name="changelog.path" value="docs/en/04_Changelogs/alpha/${tagName}.md" /></then>
<elseif>
<contains string="${tagName}" substring="beta" />
<then><property name="changelog.path" value="docs/en/04_Changelogs/beta/${tagName}.md" /></then>
</elseif>
<elseif>
<contains string="${tagName}" substring="rc" />
<then><property name="changelog.path" value="docs/en/04_Changelogs/rc/${tagName}.md" /></then>
</elseif>
<else>
<property name="changelog.path" value="docs/en/04_Changelogs/${tagName}.md" />
</else>
</if>
<if>
<available file="${frameworkdir}/${changelog.path}" />
<then>
<echo msg="Changelog exists in '${frameworkdir}/${changelog.path}', please add content manually." />
<echo msg="${changelogOutput}" />
</then>
<else>
<touch file="${frameworkdir}/${changelog.path}" />
<echo msg="# ${tagName}${line.separator}${line.separator}# Overview${line.separator}${line.separator}TODO${line.separator}${changelogOutput}" file="${frameworkdir}/${changelog.path}" />
<echo msg="Written changelog to '${frameworkdir}/${changelog.path}'." />
</else>
</if>
<input propertyname="_null" message="Now add a highlevel changelog to the file before I can commit it. Ready to commit and push?" />
<exec command="git add ${changelog.path}" dir="${frameworkdir}" />
<exec command="git commit -m 'Added ${tagName} changelog'" dir="${frameworkdir}" />
<gitpush refspec="refs/heads/${branchName}" repository="${frameworkdir}" />
</target>
<target name="translation-generate-javascript">
<foreach list="${modules},framework/admin" param="module" target="translation-generate-javascript-for-module" />
</target>
<target name="translation-generate-javascript-for-module">
<generateJavascriptI18nTask modulePath="${basedir}/${module}" />
</target>
</project>