用的是这个包: github.com/c4urself/bump2version
基本操作如下:
1. 安装
pip install bumpversion
# poetry add --dev bumpversion
2. 配置
cat .bumpversion.cfg
[bumpversion]
current_version = 1.5.0
commit = True
tag = True
[bumpversion:file:pyproject.toml]
cat pyproject.toml
[tool.poetry]
name = "zhifu"
version = "1.5.0" # 这里的版本号要跟.bumpxxx.cfg里的一致
description = ""
authors = ["waket <waketzheng@gmail.com>"]
[tool.poetry.dependencies]
python = "^3.8"
fastapi = "^0.63.0"
uvicorn = "^0.13.4"
httpx = "^0.17.0"
redis = "^3.5.3"
tortoise-orm = "^0.16.21"
celery = {extras = ["redis", "pyamqp", "msgpack"], version = "^5.0.5"}
asyncpg = "^0.22.0"
python-dotenv = "^0.15.0"
rich = "^9.13.0"
[tool.poetry.dev-dependencies]
pytest = "^6.2.2"
ipython = "^7.21.0"
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
3. 使用
bumpversion patch
# 1.5.0 -> 1.5.1
bumpversion minor
# 1.5.0 -> 1.6.0
bumpversion major
# 1.5.0 -> 2.0.0
### 2024-06-25 补充:
如果用的是Python3.10以上版本,可用fast-dev-cli,无需再配置.bumpversion.cfg
pip install fast-dev-cli
fast bump patch
# fast bump minor
# fast bump major