build.sh
988 Bytes
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
#!/bin/bash
set -e
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [[ $current_branch != "test" ]]; then
echo "当前不在 test 分支,脚本终止"
exit 3
fi
output=$(git pull --rebase)
if echo "$output" | grep -q "Updating" && echo "$output" | grep -q "Fast-forward"; then
echo "准备开始执行打包"
else
if [[ $1 != "true" ]]; then
echo "无文件变动"
exit 4
fi
echo "准备开始执行打包[强制]"
fi
mkdir -p target
rm -rf target/*
rm -rf dist
echo "yes" | pnpm install --frozen-lockfile
pnpm build:local
mv dist/* target/
git add .
status=$(git status --porcelain)
if [[ -n $status ]]; then
echo "准备提交打包后的文件"
else
echo "本地没有文件变化"
exit 4
fi
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
commit_message="📦 build(*): build [${timestamp}] "
git commit -m "${commit_message}" -n
git pull --rebase
git push
sleep 3
curl https://testjenkins.feewee.cn/job/front.admin.feewee.cn/build?token=oKyioWCW