Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # hatch-vcs 需要 tags/history 才能決定版本(build 本套件時)

- name: Install uv
uses: astral-sh/setup-uv@v5
Expand Down
23 changes: 7 additions & 16 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ name: Publish to PyPI
# 2. GitHub repo → Settings → Environments → 新增名為 `pypi` 的 environment
# (名稱要跟上面 PyPI 設定一致;可另設保護規則,例如限定 reviewer 才能發版)
#
# 發版流程(tag 驅動):
# - 先把 pyproject.toml 的 version bump 好(PyPI 版本號不可重複)
# - git tag vX.Y.Z(要跟 version 一致,下方 job 會檢查)
# - git push origin vX.Y.Z ← 推 tag 就觸發本 workflow,自動 build → 上傳 PyPI
# 發版流程(tag 驅動,版本號 = tag,不用改 pyproject.toml):
# - git tag v0.1.0
# - git push origin v0.1.0 ← 推 tag 就觸發;hatch-vcs 從 tag 算出版本 0.1.0
# 自動 build → 上傳 PyPI(PyPI 版本號不可重複,所以每次用新 tag)

on:
push:
Expand All @@ -31,22 +31,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # hatch-vcs 需要完整 history + tags 才能從 tag 算版本

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Verify pushed tag matches pyproject version
if: startsWith(github.ref, 'refs/tags/')
run: |
VERSION=$(grep -m1 '^version' pyproject.toml | sed -E 's/.*"(.*)".*/\1/')
TAG="${GITHUB_REF_NAME#v}"
echo "pyproject version: $VERSION pushed tag: $TAG"
if [ "$VERSION" != "$TAG" ]; then
echo "::error::pushed tag ($TAG) does not match pyproject version ($VERSION). Bump the version or fix the tag."
exit 1
fi

- name: Build sdist + wheel
- name: Build sdist + wheel (version derived from the pushed tag)
run: uv build

- name: Check distribution metadata
Expand Down
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "finmind-mcp"
version = "0.1.0"
dynamic = ["version"] # 版本由 git tag 決定(hatch-vcs),發版只要推 tag,不用改這裡
description = "FinMind MCP server — Taiwan / global financial data for Claude, Gemini CLI, Cursor, Windsurf, and other MCP hosts"
readme = "README.md"
license = { text = "Apache-2.0" }
Expand Down Expand Up @@ -35,9 +35,14 @@ finmind-mcp = "finmind_mcp.server:main"
dev = ["pytest>=7", "pytest-asyncio>=0.23", "respx>=0.21"]

[build-system]
requires = ["hatchling"]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

# 版本來源 = git tag(透過 hatch-vcs / setuptools-scm)。
# 推 tag vX.Y.Z → build 出來就是 X.Y.Z;非 tag commit 會是 dev 版號。
[tool.hatch.version]
source = "vcs"

[tool.hatch.build.targets.wheel]
packages = ["src/finmind_mcp"]

Expand Down
7 changes: 6 additions & 1 deletion src/finmind_mcp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""FinMind MCP server."""

__version__ = "0.1.0"
from importlib.metadata import PackageNotFoundError, version

try:
__version__ = version("finmind-mcp")
except PackageNotFoundError: # running from a source tree that isn't installed
__version__ = "0.0.0+unknown"
1 change: 0 additions & 1 deletion uv.lock

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

Loading