-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci.sh
52 lines (46 loc) · 1.05 KB
/
ci.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
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")"
mkdir -p .oss
arr=()
for dir in `ls`
do
if [ ! -s $dir/plugin.json ]; then
continue
fi
status=$(curl --head "l-os.lebai.ltd/plugin/$dir.zip" 2>/dev/null | head -n 1| cut -d$' ' -f2)
if [ "$status" != "404" ]
then
echo "更新$dir"
#continue
else
echo "发布$dir"
fi
cd $dir
if [ -s list.sh ]; then
PLUGIN_CI_LIST=`bash list.sh`
else
PLUGIN_CI_LIST=`git ls-files`
fi
zip -q -r ../.oss/$dir.zip $PLUGIN_CI_LIST
obj="{\"name\":\"$dir\", \"url\":\"https://l-os.lebai.ltd/plugin/${dir}.zip\"}"
arr+=("$obj")
cd ../
done
# 构造 JSON 数组
json="["
for ((i=0; i<${#arr[@]}; i++)); do
json+=" ${arr[$i]}"
if [ $i -lt $((${#arr[@]}-1)) ]; then
json+=","
fi
done
json+=" ]"
echo $json > .oss/info.json
cd .oss/
for file in `ls *.zip`
do
md5sum $file | cut -d ' ' -f1 > $file.md5sum
done
cd ../
ossutil -e $AWS_ENDPOINT -i $AWS_ACCESS_KEY_ID -k $AWS_SECRET_ACCESS_KEY cp -r -f -u .oss/ oss://l-os/plugin/