diff --git a/.bumpversion.cfg b/.bumpversion.cfg index f559689..8e5b6f8 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -2,6 +2,7 @@ current_version = 2.0.0 commit = False tag = False +allow_dirty = True parse = (?P\d+)\.(?P\d+)\.(?P\d+) serialize = {major}.{minor}.{patch} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 38048c6..8c1c990 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -36,13 +36,20 @@ jobs: - name: Install dependencies run: | - uv add --dev bump2version + uv sync --dev - name: Configure Git run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" + - name: Commit dependency changes if any + run: | + if [ -n "$(git status --porcelain)" ]; then + git add . + git commit -m "📦 Update dependencies" || true + fi + - name: Get current version id: current_version run: | @@ -53,7 +60,7 @@ jobs: - name: Bump version id: bump_version run: | - uv run bump2version ${{ github.event.inputs.version_type }} + uv run bump2version --allow-dirty ${{ github.event.inputs.version_type }} NEW_VERSION=$(grep '^version =' pyproject.toml | cut -d'"' -f2) echo "new=$NEW_VERSION" >> $GITHUB_OUTPUT echo "New version: $NEW_VERSION" diff --git a/scripts/release.py b/scripts/release.py index 60a909a..cdc4b11 100644 --- a/scripts/release.py +++ b/scripts/release.py @@ -39,8 +39,8 @@ def bump_version(version_type): current = get_current_version() print(f"📦 當前版本: {current}") - # 使用 bump2version - run_cmd(f"uv run bump2version {version_type}") + # 使用 bump2version with allow-dirty + run_cmd(f"uv run bump2version --allow-dirty {version_type}") new_version = get_current_version() print(f"🎉 新版本: {new_version}") @@ -56,14 +56,12 @@ def main(): print("🚀 開始發布流程...") - # 檢查是否有未提交的變更 + # 檢查 Git 狀態(僅提示,不阻止) result = run_cmd("git status --porcelain", check=False) if result.stdout.strip(): - print("⚠️ 有未提交的變更,請先提交或暫存") + print("⚠️ 有未提交的變更:") print(result.stdout) - choice = input("是否繼續? (y/N): ") - if choice.lower() != 'y': - sys.exit(1) + print("💡 將繼續執行(使用 --allow-dirty 模式)") # 更新版本 old_version, new_version = bump_version(version_type) @@ -76,7 +74,7 @@ def main(): print("🔍 檢查套件...") run_cmd("uv run twine check dist/*") - # 提交變更 + # 提交所有變更(包括版本更新) print("💾 提交版本更新...") run_cmd("git add .") run_cmd(f'git commit -m "🔖 Release v{new_version}"') diff --git a/uv.lock b/uv.lock index 4507a00..b6a92fd 100644 --- a/uv.lock +++ b/uv.lock @@ -33,6 +33,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b9/fa/123043af240e49752f1c4bd24da5053b6bd00cad78c2be53c0d1e8b975bc/backports.tarfile-1.2.0-py3-none-any.whl", hash = "sha256:77e284d754527b01fb1e6fa8a1afe577858ebe4e9dad8919e34c862cb399bc34", size = 30181 }, ] +[[package]] +name = "bump2version" +version = "1.0.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/29/2a/688aca6eeebfe8941235be53f4da780c6edee05dbbea5d7abaa3aab6fad2/bump2version-1.0.1.tar.gz", hash = "sha256:762cb2bfad61f4ec8e2bdf452c7c267416f8c70dd9ecb1653fd0bbb01fa936e6", size = 36236 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1d/e3/fa60c47d7c344533142eb3af0b73234ef8ea3fb2da742ab976b947e717df/bump2version-1.0.1-py2.py3-none-any.whl", hash = "sha256:37f927ea17cde7ae2d7baf832f8e80ce3777624554a653006c9144f8017fe410", size = 22030 }, +] + [[package]] name = "certifi" version = "2025.1.31" @@ -493,6 +502,7 @@ dev = [ [package.dev-dependencies] dev = [ + { name = "bump2version" }, { name = "pytest" }, { name = "pytest-asyncio" }, { name = "twine" }, @@ -513,6 +523,7 @@ requires-dist = [ [package.metadata.requires-dev] dev = [ + { name = "bump2version", specifier = ">=1.0.1" }, { name = "pytest", specifier = ">=7.0.0" }, { name = "pytest-asyncio", specifier = ">=0.21.0" }, { name = "twine", specifier = ">=6.1.0" },