-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.xml
91 lines (73 loc) · 3.32 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
<?xml version="1.0" encoding="utf-8"?>
<project name="CakePHP" default="release">
<property name="project.name" value="Saito"/>
<property name="build.dir" value="build"/>
<property name="git.dir" value="build/Saito"/>
<property name="dist.dir" value="dist"/>
<fileset id="release-fileset" dir="${git.dir}">
<include name="bin/**"/>
<include name="config/**"/>
<include name="docs/**"/>
<include name="logs/"/>
<include name="plugins/**"/>
<include name="src/**"/>
<include name="tmp/**"/>
<include name="vendor/**"/>
<include name="webroot/**"/>
<include name=".htaccess"/>
<include name="index.php"/>
<include name="CHANGELOG.md"/>
<include name="README.md"/>
<exclude name="**/css/src/**"/>
<exclude name="plugins/*/dev/**"/>
<exclude name="plugins/*/tests/**"/>
</fileset>
<!-- start fresh each time. Remove the dist and build dirs -->
<target name="clean-build-dir">
<delete dir="${build.dir}" includeemptydirs="true"/>
</target>
<target name="clean" depends="clean-build-dir">
<delete dir="${dist.dir}" includeemptydirs="true"/>
</target>
<target name="create-dirs" depends="clean">
<echo msg="Creating build + dist directories."/>
<mkdir dir="${build.dir}"/>
<mkdir dir="${dist.dir}"/>
</target>
<target name="release" depends="create-dirs">
<echo msg="Create release in dist/"/>
<input propertyName="git.branch" defaultValue="master" message="Branch to use?"></input>
<input propertyName="git.tag" defaultValue="head" message="Tag to use?"></input>
<echo msg="Checkout ${git.branch}"/>
<exec command="git clone -b ${git.branch} -l ../ ../${git.dir}" dir="${build.dir}"/>
<if>
<not>
<equals arg1="${git.tag}" arg2="head"/>
</not>
<then>
<echo msg="Switch to git tag ${git.tag}"/>
<exec command="git checkout tags/${git.tag}" dir="${build.dir}"/>
</then>
</if>
<!-- __SALT__ will be replaced by the composer CakePHP post task -->
<replaceregexp file="${git.dir}/config/app.php" match="__SALT__" replace="@@SALT@@"/>
<echo msg="Install composer packages"/>
<exec command="composer install --optimize-autoloader --no-dev --no-interaction" dir="${git.dir}"/>
<replaceregexp file="${git.dir}/config/app.php" match="@@SALT@@" replace="__SALT__"/>
<echo msg="Install yarn packages"/>
<exec command="yarn" dir="${git.dir}"/>
<echo msg="Build release"/>
<exec command="grunt release" dir="${git.dir}"/>
<echo msg="Moving files to build directory"/>
<move todir="${build.dir}">
<fileset refid="release-fileset"/>
</move>
<echo msg="Delete git directory"/>
<delete dir="${git.dir}" includeemptydirs="true"/>
<echo msg="Creating Zip"/>
<exec command="php -r "echo str_replace('/', '-', '${git.branch}');"" outputProperty="git.branch.clean"/>
<zip destfile="${dist.dir}/saito-release-${git.branch.clean}-${git.tag}.zip" basedir="${build.dir}"/>
<echo msg="Cleanup build dir"/>
<phingcall target="clean-build-dir"/>
</target>
</project>