forked from fis-components/components
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
177 lines (139 loc) · 3.99 KB
/
Copy pathbuild.sh
File metadata and controls
177 lines (139 loc) · 3.99 KB
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
#!/usr/bin/env bash
export ROOT=$(pwd)
git_clone () {
git clone "${1}" "${2}" #> /dev/null 2>&1
if [ "$?" != "0" ]; then
return 1
fi
return 0
}
git_update_repos () {
repos=$1
version=$2
folder=$3
node $ROOT/sync.js create-component.json $repos $version $folder
#AU
git config --global user.email "${GIT_EMAIL}"
git config --global user.name "${GIT_NAME}"
git config credential.helper "store --file=.git/credential"
echo "https://${GH_TOKEN}:@github.com" > .git/credential
git add -A -f
git commit -m "based on https://github.com/mtt-components/components/blob/master/modules/${folder}${repos}.js" -a
git push origin master
git tag -a "$version" -m "create tag $version"
git push --tags
bos_sync $repos $version
}
bos_sync () {
echo "BOS Sync ${1}@${2}"
bash $ROOT/bosSync.sh $1 $2
if [ "$?" != "0" ]; then
exit 1
fi
}
export -f git_clone
export -f git_update_repos
export -f bos_sync
sync () {
new=$1
repos=$2
build=$3
version=$4
build_dest=$5
tag=$6
rebuild=$7
folder=$8
echo "Folder is $folder"
dest="$ROOT/_$new"
echo "=SYNC ${new} from ${repos}, version: ${version}"
if [ -d "_${new}" ]; then
rm -rf "_${new}"
echo "=LOCAL rm -rf _${new}"
fi
git_clone "https://github.com/mtt-components/${new}" "_${new}"
if [ "$?" != "0" ]; then
# new origin
node $ROOT/sync.js create-repos "${new}" "${GH_TOKEN}" "${repos}" "$folder"
if [ "$?" != "0" ]; then
exit 1
fi
git_clone "https://github.com/mtt-components/${new}" "_${new}"
if [ "$?" != "0" ]; then
exit 1
fi
else
cd "_${new}"
git pull --all
found=$(git tag | grep $version)
if [ "$found" != "" ]; then
if [ "$rebuild" = "true" ]; then
echo "= Tag $version already exists, now deleting..."
#AU
git config --global user.email "${GIT_EMAIL}"
git config --global user.name "${GIT_NAME}"
git config credential.helper "store --file=.git/credential"
echo "https://${GH_TOKEN}:@github.com" > .git/credential
git tag -d "$version"
git push origin :refs/tags/$version
echo "= Clean all files"
git ls-files | xargs git rm
git commit -am "rm all files"
git push
else
echo "=TAG tag $version exists."
exit 1
fi
fi
cd $ROOT
fi
if [ -d $new ]; then
rm -rf $new
echo "=LOCAL rm -rf $new"
fi
git_clone $repos $new
if [ "$?" = "0" ]; then
cd $new
git checkout $tag
if [ "$?" != "0" ]; then
echo "=GIT: git checkout $tag fail."
exit 1
fi
# run build
if [ "$build" != "" ]; then
echo '=BUILD '$new
touch package.json
eval $build || ('=BUILD build fail.' 2>&1 || exit 1)
fi
# if [ -d "$build_dest" ]; then
# cp -rf "./${build_dest}" "$dest"
# fi
# if [ -d "./dist" ]; then
# cp -rf "./dist" "$dest"
# fi
else
if [ "$build" != "" ]; then
mkdir -p $new
cd $new
touch package.json
echo '=BUILD '$new
eval $build || ('=BUILD build fail.' 2>&1 || exit 1)
fi
fi
node $ROOT/sync.js move "$new" "$version" "$(pwd)" "$dest" "$folder"
node $ROOT/sync.js convert "$new" "$version" "$dest" "$folder"
if [ "$?" != "0" ]; then
echo '=ROADMAP move fail'
exit 1
fi
cd "$dest"
echo "=CD $dest"
git_update_repos $new $version $folder
cd $ROOT
}
export -f sync
main () {
echo '#START build.sh'
sync "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8"
echo '#END build.sh'
}
main "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8"