Skip to content

ci: GitHub Actions CI + PyPI 自動發佈(推 tag 觸發,OIDC)#1

Merged
linsamtw merged 1 commit into
masterfrom
ci/pypi-publish
May 25, 2026
Merged

ci: GitHub Actions CI + PyPI 自動發佈(推 tag 觸發,OIDC)#1
linsamtw merged 1 commit into
masterfrom
ci/pypi-publish

Conversation

@linsamtw
Copy link
Copy Markdown
Contributor

內容

新增兩個 GitHub Actions workflow:

ci.yml — 持續整合

push 到 master / 開 PR 時,在 Python 3.10/3.11/3.12 上跑:pytest + smoke.py + chatgpt/build_instructions.py(順便當 8000 字上限的守門)。全部離線。
regression/runner.py 會打 live API、需 FINMIND_TOKEN,所以不放 CI,發版前人工跑。)

publish.yml — 自動發佈 PyPI(推 tag 觸發

推一個版本 tag(vX.Y.Z)就自動 uv buildtwine check → 上傳 PyPI。用 PyPI Trusted Publishing(OIDC)pypa/gh-action-pypi-publish不存任何 API token。會檢查「推的 tag 要跟 pyproject.toml 的 version 一致」,不一致就擋下。

⚠️ Merge 後、第一次發版前要做的一次性設定(PyPI 端,我做不了)

  1. PyPI 加 pending trusted publisherhttps://pypi.org/manage/account/publishing/):
    • Project name finmind-mcp · Owner FinMind · Repo FinMind-MCP · Workflow publish.yml · Environment pypi
    • (專案還沒上 PyPI 沒關係,pending publisher 第一次發版會自動建立專案)
  2. GitHub repo → Settings → Environments 新增名為 pypi 的 environment(名稱要跟 PyPI 設定一致)。

之後的發版流程

# 1. bump pyproject.toml 的 version(例如 0.1.0 → 0.1.1)
# 2. 打 tag 並推上去 → 自動觸發發佈
git tag v0.1.0
git push origin v0.1.0

🤖 Generated with Claude Code

- ci.yml: on push(master)/PR, run pytest + smoke + the ChatGPT instructions
  build (8000-char guard) across Python 3.10/3.11/3.12. All offline — the
  live-API regression runner stays manual (needs FINMIND_TOKEN).
- publish.yml: pushing a version tag (vX.Y.Z) builds with `uv build`, runs
  `twine check`, then uploads via PyPI Trusted Publishing (OIDC,
  pypa/gh-action-pypi-publish) — no API token stored. Guards that the pushed
  tag matches the pyproject version. Also runnable via workflow_dispatch.

One-time PyPI-side setup (documented in publish.yml header): add a pending
trusted publisher (project finmind-mcp, repo FinMind/FinMind-MCP, workflow
publish.yml, environment pypi) + create the `pypi` GitHub environment.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@linsamtw linsamtw merged commit a130535 into master May 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant