forked from FineUploader/bower-dist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·71 lines (54 loc) · 1.65 KB
/
build.sh
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
#!/bin/bash
set -e
# usage color "31;0" "string"
# 0 default
# 5 blink, 1 strong, 4 underlined
# fg: 31 red, 32 green, 33 yellow, 34 blue, 35 purple, 36 cyan, 37 white
# bg: 40 black, 41 red, 44 blue, 45 purple
e() {
printf '\033[%sm%s\033[m\n' "$@"
}
if [ -z $1 ]; then
e '31;0' 'Please specify Fine-uploader version you want to build.'
e '31;0' 'Example: ./build.sh 5.11.8'
e '31;0' ' See: https://github.com/FineUploader/fine-uploader/releases'
exit;
fi
version=$1
commit="Bump v${version}"
e '33;0' 'Entering FineUploader/fine-uploader src directory'
cd src && git checkout -qf master
if [ -f 'npm-debug.log' ]; then
e '33;0' "Seems you've got an error in previous build"
rm npm-debug.log
git branch -qD "v${version}"
fi
e '33;0' "Check out version $version"
git pull -q origin && git checkout -qb "v${version}" $version
if [[ $2 == '--reinstall-dep' ]]; then
e '33;0' 'Removing existing node_modules dir'
rm -rf node_modules;
fi
if [ ! -d 'node_modules' ]; then
e '33;0' 'Installing dependencies'
npm install -q;
fi
e '33;0' 'Build FineUploader/fine-uploader'
make build
e '33;0' 'Clean up dist folder'
rm -rf ../dist/*
e '33;0' 'Copying build files'
cp -rf _build/* ../dist/
e '33;0' 'Back to master branch'
git checkout master && git branch -D "v${version}"
e '33;0' 'Update version number'
cd ..
sed -i -e "s/[0-9].[0-9].[0-9]/${version}/" bower.json
sed -i -e "s/[0-9].[0-9].[0-9]/${version}/" README.md
sed -i -e "s/[0-9].[0-9].[0-9]/${version}/" build.sh
e '33;0' "${commit}"
git add -A && git commit -am "${commit}" -q
if [[ $2 = '--release-tag' ]] || [[ $3 = '--release-tag' ]]; then
git tag -s $version -m "${commit}"
fi
e '32;0' 'Done!'