-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (59 loc) · 2.3 KB
/
Copy pathpublish.yml
File metadata and controls
68 lines (59 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Publish to PyPI
# 推一個新的版本 tag(vX.Y.Z)就自動 build + 上傳 PyPI(也可手動 workflow_dispatch)。
# 用 PyPI Trusted Publishing(OIDC)—— 不需要存任何 API token / secret。
#
# 一次性設定(使用者在 PyPI 端做,我做不了):
# 1. https://pypi.org/manage/account/publishing/ → Add a new pending publisher
# PyPI Project Name: finmind-mcp
# Owner: FinMind
# Repository name: FinMind-MCP
# Workflow name: publish.yml
# Environment name: pypi
# (專案還沒上 PyPI 沒關係,用 "pending publisher",第一次發版會自動建立專案)
# 2. GitHub repo → Settings → Environments → 新增名為 `pypi` 的 environment
# (名稱要跟上面 PyPI 設定一致;可另設保護規則,例如限定 reviewer 才能發版)
#
# 發版流程(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:
tags:
- "v[0-9]*" # vX.Y.Z
- "[0-9]*" # 也接受沒有 v 前綴的 X.Y.Z
workflow_dispatch:
jobs:
build:
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: Build sdist + wheel (version derived from the pushed tag)
run: uv build
- name: Check distribution metadata
run: uvx twine check dist/*
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
pypi-publish:
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/finmind-mcp/
permissions:
id-token: write # OIDC token for PyPI Trusted Publishing — no password needed
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1