Skip to content

Commit

Permalink
feat: 使用commitizen管理版本号
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxi committed Jul 6, 2024
1 parent be62d8a commit a032a1d
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 46 deletions.
36 changes: 2 additions & 34 deletions newversion.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,5 @@
#!/bin/bash

set -e
cz bump --check-consistency --increment patch

version_file=./pyproject.toml
init_file=./xiaomusic/__init__.py
# 获取当前版本号
current_version=$(grep -oE "version = \"[0-9]+\.[0-9]+\.[0-9]+\"" $version_file | cut -d'"' -f2)
echo "当前版本号: "$current_version

# 将版本号分割成三部分
major=$(echo $current_version | cut -d'.' -f1)
minor=$(echo $current_version | cut -d'.' -f2)
patch=$(echo $current_version | cut -d'.' -f3)

echo "major: $major"
echo "minor: $minor"
echo "patch: $patch"

# 将补丁号加1
patch=$((patch + 1))

# 生成新版本号
new_version="$major.$minor.$patch"

# 将新版本号写入文件
sed -i "s/version.*/version = \"$new_version\"/g" $version_file
sed -i "s/__version__.*/__version__ = \"$new_version\"/g" $init_file

echo "新版本号:$new_version"

git diff
git add $version_file
git add $init_file
git commit -m "new version v$new_version"
git tag v$new_version
git push -u origin main --tags
#git push -u origin main --tags
167 changes: 165 additions & 2 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 16 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "xiaomusic"
version = "0.1.95"
description = "Play Music with xiaomi AI speaker"
authors = [
{name = "涵曦", email = "[email protected]"},
{name = "涵曦", email = "[email protected]"},
]
dependencies = [
"aiohttp>=3.8.6",
Expand Down Expand Up @@ -33,19 +33,22 @@ build-backend = "pdm.backend"
lint = [
"ruff>=0.4.8",
]
dev = [
"commitizen>=3.27.0",
]
[tool.ruff]
lint.select = [
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"E", # pycodestyle - Error
"F", # Pyflakes
"I", # isort
"W", # pycodestyle - Warning
"UP", # pyupgrade
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"E", # pycodestyle - Error
"F", # Pyflakes
"I", # isort
"W", # pycodestyle - Warning
"UP", # pyupgrade
]
lint.ignore = [
"E501", # line-too-long
"W191", # tab-indentation
"E501", # line-too-long
"W191", # tab-indentation
]
include = ["**/*.py", "**/*.pyi", "**/pyproject.toml"]

Expand All @@ -63,3 +66,6 @@ version_scheme = "pep440"
version_provider = "pep621"
update_changelog_on_bump = true
major_version_zero = true
version_files = [
"xiaomusic/__init__.py",
]

0 comments on commit a032a1d

Please sign in to comment.