提交 | 用户 | 时间
|
58d006
|
1 |
#!/bin/bash |
A |
2 |
set -e |
|
3 |
|
|
4 |
echo -n "Enter the version for this release: " |
|
5 |
|
|
6 |
read ver |
|
7 |
|
|
8 |
if [ ! $ver ]; then |
|
9 |
echo "Invalid version." |
|
10 |
exit |
|
11 |
fi |
|
12 |
|
|
13 |
name="select2" |
|
14 |
js="$name.js" |
|
15 |
mini="$name.min.js" |
|
16 |
css="$name.css" |
|
17 |
release="$name-$ver" |
|
18 |
tag="$ver" |
|
19 |
branch="build-$ver" |
|
20 |
curbranch=`git branch | grep "*" | sed "s/* //"` |
|
21 |
timestamp=$(date) |
|
22 |
tokens="s/@@ver@@/$ver/g;s/\@@timestamp@@/$timestamp/g" |
|
23 |
remote="github" |
|
24 |
|
|
25 |
echo "Updating Version Identifiers" |
|
26 |
|
|
27 |
sed -E -e "s/\"version\": \"([0-9\.]+)\",/\"version\": \"$ver\",/g" -i "" bower.json select2.jquery.json |
|
28 |
git add bower.json |
|
29 |
git add select2.jquery.json |
|
30 |
git commit -m "modified version identifiers in descriptors for release $ver" |
|
31 |
git push |
|
32 |
|
|
33 |
git branch "$branch" |
|
34 |
git checkout "$branch" |
|
35 |
|
|
36 |
echo "Tokenizing..." |
|
37 |
|
|
38 |
find . -name "$js" | xargs -I{} sed -e "$tokens" -i "" {} |
|
39 |
find . -name "$css" | xargs -I{} sed -e "$tokens" -i "" {} |
|
40 |
sed -e "s/latest/$ver/g" -i "" bower.json |
|
41 |
|
|
42 |
git add "$js" |
|
43 |
git add "$css" |
|
44 |
|
|
45 |
echo "Minifying..." |
|
46 |
|
|
47 |
echo "/*" > "$mini" |
|
48 |
cat LICENSE | sed "$tokens" >> "$mini" |
|
49 |
echo "*/" >> "$mini" |
|
50 |
|
|
51 |
curl -s \ |
|
52 |
--data-urlencode "js_code@$js" \ |
|
53 |
http://marijnhaverbeke.nl/uglifyjs \ |
|
54 |
>> "$mini" |
|
55 |
|
|
56 |
git add "$mini" |
|
57 |
|
|
58 |
git commit -m "release $ver" |
|
59 |
|
|
60 |
echo "Tagging..." |
|
61 |
git tag -a "$tag" -m "tagged version $ver" |
|
62 |
git push "$remote" --tags |
|
63 |
|
|
64 |
echo "Cleaning Up..." |
|
65 |
|
|
66 |
git checkout "$curbranch" |
|
67 |
git branch -D "$branch" |
|
68 |
|
|
69 |
echo "Done" |