-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpublish
executable file
·71 lines (60 loc) · 2.16 KB
/
publish
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
# Generatd by ChatGPT
# 1. 接受参数并赋值给变量 protocol_ver,若未传参则提示用户并退出
if [ $# -eq 0 ]
then
echo "Please give in the param!"
exit 1
else
protocol_ver=$1
fi
# 2. 检查目录 Protobuf-$protocol_ver/Protos 是否存在,不存在则提示用户并退出
if [ ! -d "Protobuf-$protocol_ver/Protos" ]
then
echo "Protobuf-$protocol_ver/Protos doesn't exist!"
exit 1
fi
# 3. 创建文件夹 Protobuf-$protocol_ver/Compiled
mkdir -p "Protobuf-$protocol_ver/Compiled"
# 4. 编译proto文件
# echo "Start compiling protos..."
# protoc --proto_path="Protobuf-$protocol_ver/Protos" --csharp_out="Protobuf-$protocol_ver/Compiled" "Protobuf-$protocol_ver/Protos/*.proto"
# 5. 创建文件夹
mkdir -p "EasyProtobuf Build/$protocol_ver/bin"
# 6. Call dotnet publish and pass the version attribute
echo "Start building program..."
dotnet publish EasyProtobuf.csproj -c Release -p:protobuf_version="$protocol_ver" -o "EasyProtobuf Build/$protocol_ver/bin"
# 7. Check if the publish was successful or not
if [ $? -eq 0 ]
then
echo "Publish Successful."
else
echo "Publish Failed."
exit 1
fi
# 8. Copy the config and resources
if [ ! -f "config-$protocol_ver.json" ]
then
cp "config_example.json" "config-$protocol_ver.json"
fi
cp -f "config-$protocol_ver.json" "EasyProtobuf Build/$protocol_ver/config-$protocol_ver.json"
cp -r -f resources "EasyProtobuf Build/$protocol_ver/resources"
cp -f "Handbook.md" "EasyProtobuf Build/$protocol_ver/Handbook.md"
cp -f "Handbook_CN.md" "EasyProtobuf Build/$protocol_ver/Handbook_CN.md"
cp -f "LICENSE" "EasyProtobuf Build/$protocol_ver/LICENSE"
# 9. Write run.sh and run-win.bat
cat > "EasyProtobuf Build/$protocol_ver/run" <<EOF
#!/bin/bash
export EASYPROTOBUF_PROTOCOL_VERSION=$protocol_ver
dotnet ./bin/EasyProtobuf.dll \$*
EOF
echo "run shell script Generated at EasyProtobuf Build/$protocol_ver."
chmod +x "EasyProtobuf Build/$protocol_ver/run"
cat > "EasyProtobuf Build/$protocol_ver/run.bat" <<EOF
set EASYPROTOBUF_PROTOCOL_VERSION=$protocol_ver
dotnet ./bin/EasyProtobuf.dll %*
EOF
echo "run.bat Generated at EasyProtobuf Build/$protocol_ver."
# Display success message and exit
echo "Done!"
exit 0