-
Notifications
You must be signed in to change notification settings - Fork 60
/
deploy.sh
executable file
·37 lines (28 loc) · 962 Bytes
/
deploy.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
#!/bin/bash
# 项目名称
project="auto_coder"
# 使用Python一行命令提取版本号,减少对grep和cut的依赖
version=$(python -c "with open('src/autocoder/version.py') as f: print([line.split('=')[1].strip().strip('\"') for line in f if '__version__' in line][0])")
echo "Version: $version"
# 清理dist目录
echo "Clean dist"
rm -rf ./dist/*
# 卸载当前安装的项目版本
echo "Uninstall ${project}"
pip uninstall -y ${project}
# 构建项目
echo "Build ${project} ${version}"
python setup.py sdist bdist_wheel
cd ./dist/
# 安装新构建的项目版本
echo "Install ${project} ${version}"
pip install ${project}-${version}-py3-none-any.whl && cd -
# 默认模式设定
export MODE=${MODE:-"release"}
# 发布模式下的操作
if [[ ${MODE} == "release" ]]; then
git tag v${version}
git push origin v${version} # 请根据实际情况使用正确的远程仓库名
echo "Upload ${project} ${version}"
twine upload dist/*
fi