ci: 版本改由 git tag 決定(hatch-vcs)—— 發版不用再改 pyproject#2
Merged
Conversation
發版應該只要推 tag,不該每次手改 pyproject.toml 的 version。 - pyproject:version 改成 hatch-vcs 動態版本(source = "vcs"),移除寫死的 version(dynamic = ["version"]);build-system 加 hatch-vcs。 - __init__.py:__version__ 改從 importlib.metadata 讀,不再寫死字串。 - publish.yml:拿掉「tag vs pyproject version」守門(不需要了,tag 本身就是 版本);checkout 改 fetch-depth: 0 讓 hatch-vcs 讀得到 tags。 - ci.yml:checkout fetch-depth: 0(build 本套件要靠 tags 算版本)。 之後發版流程就是: git tag v0.1.0 && git push origin v0.1.0 hatch-vcs 會把 tag 變成套件版本;非 tag commit 則是 dev 版號。本機已驗證: uv build + twine check 過、31 tests 過、knowledge 仍打包、__version__ 正常。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The finmind-mcp editable entry no longer pins a static version now that the package version is derived from git tags via hatch-vcs (see this branch's pyproject change). Regenerated lockfile drops the stale version = "0.1.0". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
為什麼
承上一個發版測試:推 tag
0.0.1時被「tag 要等於 pyproject version(0.1.0)」的守門擋下。問題不在守門,而在根本不該每次發版都手改pyproject.toml。改成讓 git tag 當版本的唯一來源。改了什麼
pyproject.toml:version改成hatch-vcs動態版本([tool.hatch.version] source = "vcs"),移除寫死的version(改dynamic = ["version"]),build-system 加hatch-vcs。src/finmind_mcp/__init__.py:__version__改用importlib.metadata讀,不再寫死。publish.yml:拿掉「tag vs pyproject version」守門(不需要了);checkout加fetch-depth: 0讓 hatch-vcs 讀得到 tags。ci.yml:checkout加fetch-depth: 0。發版流程(之後)
git tag v0.1.0 git push origin v0.1.0 # 就這樣,不用碰 pyprojecthatch-vcs 會把 tag
v0.1.0變成套件版本0.1.0;非 tag 的 commit 會 build 成 dev 版號(例0.0.2.dev3+g…)。已驗證(本機)
uv build從 git 算出版本(0.0.2.dev0+g…,因為現在 HEAD 在 tag 之後)、twine checkPASSED、pytest31 過、knowledge 6 檔仍打包進 wheel、__version__正常解析。注意
0.0.1沒有發出任何 PyPI 版本(卡在 build 前的守門),可留可刪。要的話我幫你刪掉遠端0.0.1。pypienvironment 一次性設定(見 publish.yml 註解)。🤖 Generated with Claude Code