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
|
#!/bin/bash
# Syntax: build.sh version
# Setup environment once:
# $ curl -sS https://getcomposer.org/installer | php
# git clone -- https://github.com/piwik/piwik.git /home/piwik-builds/builds/piwik_last_version || die "Problem checking out the last version tag"
# Before running this script, tag a new version:
# $ git tag 1.11-b3
# $ git push origin tags/1.11-b3
VERSION="$1"
DEST_PATH=/home/piwik-builds/builds
URL_REPO=https://github.com/piwik/piwik.git
# repo should be in DEST_PATH/piwik_last_version eg. /home/piwik-builds/builds/piwik_last_version
HTTP_PATH=/home/piwik-builds/www/builds.piwik.org
API_SCP_LATEST=piwik-api@localhost:/home/piwik-api/www/api.piwik.org/
WWW_SCP_LATEST=piwik@localhost:/home/piwik/www/
# report error and exit
function die() {
echo -e "$0: $1"
exit 2
}
# clean up the workspace
function cleanupWorkspace() {
rm -rf piwik
rm -f *.html
rm -f *.xml
rm -f *.sql
rm -f *.md
rm -f *.html.*
}
# organize files for packaging
function organizePackage() {
curl -sS https://getcomposer.org/installer | php
php composer.phar install --no-dev
cd ../
rm -rf piwik/composer.phar
rm -rf piwik/vendor/twig/twig/test/
rm -rf piwik/vendor/twig/twig/doc/
rm -rf piwik/vendor/symfony/console/Symfony/Component/Console/Tests
rm -rf piwik/vendor/symfony/console/Symfony/Component/Console/Resources/bin
rm -rf piwik/vendor/piwik/device-detector/Tests/
rm -rf piwik/libs/PhpDocumentor-1.3.2/
rm -rf piwik/libs/FirePHPCore/
rm -f piwik/libs/open-flash-chart/php-ofc-library/ofc_upload_image.php
rm -rf piwik/tmp/*
rm -rf piwik/tmp/.gitkeep
rm -f piwik/misc/updateLanguageFiles.sh
rm -f piwik/misc/others/db-schema*
rm -f piwik/misc/others/diagram_general_request*
rm -f piwik/.travis*
# delete submodules empty dirs
for path_to_delete in `cat piwik/.gitmodules | grep "path = " | sed "s/.*path = //"` ; do rmdir piwik/$path_to_delete; done
rm -rf piwik/.git*
cp piwik/tests/README.md .
find piwik -name 'tests' -type d -prune -exec rm -rf {} \;
mkdir piwik/tests
mv README.md piwik/tests/
cp piwik/misc/How\ to\ install\ Piwik.html .
if [ -e piwik/misc/package ]; then
cp piwik/misc/package/WebAppGallery/*.* .
rm -rf piwik/misc/package/
else
if [ -e piwik/misc/WebAppGallery ]; then
cp piwik/misc/WebAppGallery/*.* .
rm -rf piwik/misc/WebAppGallery
fi
fi
find piwik -type f -printf '%s ' -exec md5sum {} \; \
| grep -v "user/.htaccess" \
| egrep -v 'manifest.inc.php|autoload.php|autoload_real.php' \
| sed '1,$ s/\([0-9]*\) \([a-z0-9]*\) *piwik\/\(.*\)/\t\t"\3" => array("\1", "\2"),/;' \
| sort \
| sed '1 s/^/<?php\n\/\/ This file is automatically generated during the Piwik build process \
namespace Piwik;\nclass Manifest {\n\tstatic $files=array(\n/; $ s/$/\n\t);\n}/' \
> piwik/config/manifest.inc.php
}
if [ -z "$VERSION" ]; then
die "Expected a version number as a parameter"
fi
# Fail script, if Piwik has already been built, to prevent re-building a given release
destination=$HTTP_PATH/piwik-$VERSION.zip
if [ -f "$destination" ]
then
die "Piwik $VERSION has already been packaged. You must increase Piwik version number before packaging Piwik."
fi
############################
echo "Starting build...."
############################
# Setting umask so it works for most users, see https://github.com/piwik/piwik/issues/3869
UMASK=`umask`
umask 0022
if [ ! -e $DEST_PATH ] ; then
echo "Destination directory does not exist... Creating it!";
mkdir -p $DEST_PATH;
fi
cd $DEST_PATH
cleanupWorkspace
if [ ! -e $DEST_PATH/piwik_last_version ] ; then
git clone -- $URL_REPO $DEST_PATH/piwik_last_version
fi
echo "checkout repository for tag $VERSION..."
cd $DEST_PATH/piwik_last_version
git checkout master
git pull
git checkout tags/$VERSION
if [ $? -eq 1 ] ; then
echo "Tag $VERSION does not exist in repository"
fi
echo "copying files to a new directory..."
cd ..
rm -Rf piwik
cp -R piwik_last_version piwik
cd piwik
git checkout master
git pull
if [ `git describe --exact-match --tags HEAD` != "$VERSION" ]
then
echo "=====> could not checkout to the tag for this version, make sure tag exists <======"
exit 1
fi
cd $DEST_PATH/piwik
git checkout tags/$VERSION
echo "preparing release $VERSION"
echo `grep "'$VERSION'" core/Version.php`
if [ `grep "'$VERSION'" core/Version.php | wc -l` -ne 1 ]; then
echo "version $VERSION does not match core/Version.php";
exit
fi
echo "organizing files and generating manifest file..."
organizePackage
echo "packaging release..."
zip -r piwik-$VERSION.zip piwik How\ to\ install\ Piwik.html > /dev/null
tar -czf piwik-$VERSION.tar.gz piwik How\ to\ install\ Piwik.html
mv piwik-$VERSION.{zip,tar.gz} $HTTP_PATH
zip -r piwik-$VERSION-WAG.zip piwik *.xml *.sql > /dev/null 2> /dev/null
mkdir $HTTP_PATH/WebAppGallery 2> /dev/null
mv piwik-$VERSION-WAG.zip $HTTP_PATH/WebAppGallery/piwik-$VERSION.zip
# setting back umask
umask $UMASK
if [ `echo $VERSION | grep -E 'rc|b|a|alpha|beta|dev' -i | wc -l` -eq 1 ]; then
if [ `echo $VERSION | grep -E 'rc|b|beta' -i | wc -l` -eq 1 ]; then
echo "Beta or RC release";
echo $VERSION > $HTTP_PATH/LATEST_BETA
fi
echo "build finished! http://builds.piwik.org/piwik-$VERSION.zip"
else
echo "Stable release";
#hard linking piwik.org/latest.zip to the newly created build
for i in zip tar.gz; do
ln -sf $HTTP_PATH/piwik-$VERSION.$i $HTTP_PATH/latest.$i
ln -sf $HTTP_PATH/piwik-$VERSION.$i $HTTP_PATH/piwik-latest.$i
ln -sf $HTTP_PATH/piwik-$VERSION.$i $HTTP_PATH/piwik.$i
done
# record filesize in Mb
ls -l $HTTP_PATH/piwik-$VERSION.zip | awk '/d|-/{printf("%.3f %s\n",$5/(1024*1024),$9)}' > LATEST_SIZE
echo $VERSION > $HTTP_PATH/LATEST
echo $VERSION > $HTTP_PATH/LATEST_BETA
CMD="scp $HTTP_PATH/LATEST $API_SCP_LATEST"
echo $CMD
$CMD
CMD="scp $HTTP_PATH/LATEST LATEST_SIZE $WWW_SCP_LATEST"
echo $CMD
$CMD
SHA1_WINDOWS="$(sha1sum $HTTP_PATH/WebAppGallery/piwik-$VERSION.zip | cut -d' ' -f1)"
echo -e "Sending email to Microsoft web team \n\n"
echo -e "Hello, \n\n\
We are proud to announce a new release for Piwik! \n\
Piwik $VERSION can be downloaded at: http://builds.piwik.org/WebAppGallery/piwik-$VERSION.zip \n\
SHA1 checksum is: $SHA1_WINDOWS \n\n\
Please consult the changelog for list of closed tickets: http://piwik.org/changelog/ \n\n\
We're looking forward to seeing this Piwik version on Microsoft Web App Gallery. \n\
If you have any question, feel free to ask at feedback@piwik.org. \n\n\
Thank you,\n\n\
Piwik team" | mail -s"New Piwik Version $VERSION" "appgal@microsoft.com,hello@piwik.org"
echo "build finished! http://builds.piwik.org/piwik.zip"
fi
cleanupWorkspace
|