redshift-comment-mcp 0.1.0a0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- redshift_comment_mcp-0.1.0a0/.github/BRANCH_PROTECTION_GUIDE.md +72 -0
- redshift_comment_mcp-0.1.0a0/.github/CODEOWNERS +16 -0
- redshift_comment_mcp-0.1.0a0/.github/DEPLOYMENT.md +238 -0
- redshift_comment_mcp-0.1.0a0/.github/workflows/publish.yml +154 -0
- redshift_comment_mcp-0.1.0a0/.github/workflows/test-publish.yml +166 -0
- redshift_comment_mcp-0.1.0a0/.github/workflows/test.yml +37 -0
- redshift_comment_mcp-0.1.0a0/.gitignore +105 -0
- redshift_comment_mcp-0.1.0a0/LICENSE +21 -0
- redshift_comment_mcp-0.1.0a0/PKG-INFO +211 -0
- redshift_comment_mcp-0.1.0a0/README.md +168 -0
- redshift_comment_mcp-0.1.0a0/implementation_guide.md +842 -0
- redshift_comment_mcp-0.1.0a0/pyproject.toml +43 -0
- redshift_comment_mcp-0.1.0a0/setup.cfg +4 -0
- redshift_comment_mcp-0.1.0a0/src/redshift_comment_mcp/__init__.py +0 -0
- redshift_comment_mcp-0.1.0a0/src/redshift_comment_mcp/_version.py +34 -0
- redshift_comment_mcp-0.1.0a0/src/redshift_comment_mcp/connection.py +81 -0
- redshift_comment_mcp-0.1.0a0/src/redshift_comment_mcp/redshift_tools.py +135 -0
- redshift_comment_mcp-0.1.0a0/src/redshift_comment_mcp/server.py +56 -0
- redshift_comment_mcp-0.1.0a0/src/redshift_comment_mcp.egg-info/PKG-INFO +211 -0
- redshift_comment_mcp-0.1.0a0/src/redshift_comment_mcp.egg-info/SOURCES.txt +25 -0
- redshift_comment_mcp-0.1.0a0/src/redshift_comment_mcp.egg-info/dependency_links.txt +1 -0
- redshift_comment_mcp-0.1.0a0/src/redshift_comment_mcp.egg-info/entry_points.txt +2 -0
- redshift_comment_mcp-0.1.0a0/src/redshift_comment_mcp.egg-info/requires.txt +8 -0
- redshift_comment_mcp-0.1.0a0/src/redshift_comment_mcp.egg-info/top_level.txt +1 -0
- redshift_comment_mcp-0.1.0a0/tests/__init__.py +0 -0
- redshift_comment_mcp-0.1.0a0/tests/test_connection.py +173 -0
- redshift_comment_mcp-0.1.0a0/tests/test_tools.py +130 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Main 分支保護設定指南
|
|
2
|
+
|
|
3
|
+
## 設定位置
|
|
4
|
+
前往 Repository → Settings → Branches → Add rule
|
|
5
|
+
|
|
6
|
+
## 建議的保護規則
|
|
7
|
+
|
|
8
|
+
### Branch name pattern
|
|
9
|
+
```
|
|
10
|
+
main
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### 保護設定
|
|
14
|
+
|
|
15
|
+
#### ✅ 必須啟用的保護項目:
|
|
16
|
+
- **Require a pull request before merging**
|
|
17
|
+
- Required number of approvals before merging: `1`
|
|
18
|
+
- Dismiss stale PR approvals when new commits are pushed
|
|
19
|
+
- Require review from code owners (如果有 CODEOWNERS)
|
|
20
|
+
|
|
21
|
+
- **Require status checks to pass before merging**
|
|
22
|
+
- Require branches to be up to date before merging
|
|
23
|
+
- Status checks required:
|
|
24
|
+
- `test` (來自 test.yml workflow)
|
|
25
|
+
|
|
26
|
+
- **Restrict pushes that create files larger than 100MB**
|
|
27
|
+
|
|
28
|
+
- **Do not allow force pushes**
|
|
29
|
+
|
|
30
|
+
- **Do not allow deletions**
|
|
31
|
+
|
|
32
|
+
#### ⚠️ 重要設定:
|
|
33
|
+
- **Include administrators** ✅
|
|
34
|
+
- 這確保即使是 repository 擁有者也必須遵循保護規則
|
|
35
|
+
- 避免意外的直接推送到 main
|
|
36
|
+
|
|
37
|
+
## 工作流程影響
|
|
38
|
+
|
|
39
|
+
### 正常開發流程:
|
|
40
|
+
1. 從 main 建立 feature 分支
|
|
41
|
+
2. 開發完成後建立 Pull Request
|
|
42
|
+
3. 等待 CI 測試通過
|
|
43
|
+
4. 自行 approve 並合併 PR
|
|
44
|
+
5. 刪除 feature 分支
|
|
45
|
+
|
|
46
|
+
### GitHub Actions 相容性:
|
|
47
|
+
- ✅ CI/CD workflows 可以正常運作
|
|
48
|
+
- ✅ 自動發布流程不受影響
|
|
49
|
+
- ✅ 測試必須通過才能合併
|
|
50
|
+
|
|
51
|
+
## 例外情況
|
|
52
|
+
|
|
53
|
+
如果緊急需要直接推送到 main:
|
|
54
|
+
1. 暫時停用保護規則
|
|
55
|
+
2. 進行緊急修復
|
|
56
|
+
3. 立即重新啟用保護規則
|
|
57
|
+
|
|
58
|
+
## 額外建議
|
|
59
|
+
|
|
60
|
+
### 建立 CODEOWNERS 檔案 (可選)
|
|
61
|
+
在 repository 根目錄建立 `.github/CODEOWNERS`:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
# 全域代碼擁有者
|
|
65
|
+
* @kouko
|
|
66
|
+
|
|
67
|
+
# 特定檔案的擁有者
|
|
68
|
+
.github/workflows/* @kouko
|
|
69
|
+
pyproject.toml @kouko
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
這樣可以確保重要檔案的變更需要你的 review。
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# 代碼擁有者設定
|
|
2
|
+
# 確保重要檔案的變更需要特定人員的審查
|
|
3
|
+
|
|
4
|
+
# 全域設定 - 所有檔案都需要 kouko 的審查
|
|
5
|
+
* @kouko
|
|
6
|
+
|
|
7
|
+
# GitHub Actions workflows - 需要額外謹慎
|
|
8
|
+
.github/workflows/* @kouko
|
|
9
|
+
|
|
10
|
+
# 專案核心配置檔案
|
|
11
|
+
pyproject.toml @kouko
|
|
12
|
+
LICENSE @kouko
|
|
13
|
+
|
|
14
|
+
# 重要文檔
|
|
15
|
+
README.md @kouko
|
|
16
|
+
.github/DEPLOYMENT.md @kouko
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
# GitHub Actions 自動化部署指南
|
|
2
|
+
|
|
3
|
+
本專案使用 GitHub Actions 來自動化測試和發布流程。
|
|
4
|
+
|
|
5
|
+
## 設定步驟
|
|
6
|
+
|
|
7
|
+
### 1. 設定 API Tokens
|
|
8
|
+
|
|
9
|
+
#### PyPI API Token
|
|
10
|
+
1. 前往 [PyPI Account Settings](https://pypi.org/manage/account/)
|
|
11
|
+
2. 點選 "Add API token"
|
|
12
|
+
3. 設定 Token 名稱(例如:`redshift-comment-mcp-github`)
|
|
13
|
+
4. 選擇 Scope:選擇特定專案或 "Entire account"
|
|
14
|
+
5. 複製生成的 Token(格式:`pypi-...`)
|
|
15
|
+
|
|
16
|
+
#### TestPyPI API Token
|
|
17
|
+
1. 前往 [TestPyPI Account Settings](https://test.pypi.org/manage/account/)
|
|
18
|
+
2. 點選 "Add API token"
|
|
19
|
+
3. 設定 Token 名稱(例如:`redshift-comment-mcp-test`)
|
|
20
|
+
4. 選擇 Scope:"Entire account"(TestPyPI 通常選這個)
|
|
21
|
+
5. 複製生成的 Token(格式:`pypi-...`)
|
|
22
|
+
|
|
23
|
+
### 2. 在 GitHub 中設定 Secrets
|
|
24
|
+
|
|
25
|
+
1. 前往你的 GitHub Repository
|
|
26
|
+
2. 點選 **Settings** → **Secrets and variables** → **Actions**
|
|
27
|
+
3. 分別添加兩個 Secrets:
|
|
28
|
+
|
|
29
|
+
**PyPI Token:**
|
|
30
|
+
- Name: `PYPI_API_TOKEN`
|
|
31
|
+
- Value: 貼上 PyPI API Token
|
|
32
|
+
|
|
33
|
+
**TestPyPI Token:**
|
|
34
|
+
- Name: `TEST_PYPI_API_TOKEN`
|
|
35
|
+
- Value: 貼上 TestPyPI API Token
|
|
36
|
+
|
|
37
|
+
## 工作流程說明
|
|
38
|
+
|
|
39
|
+
### 自動測試 (.github/workflows/test.yml)
|
|
40
|
+
|
|
41
|
+
**觸發條件:**
|
|
42
|
+
- Push 到 `main` 或 `develop` 分支
|
|
43
|
+
- Pull Request 到 `main` 或 `develop` 分支
|
|
44
|
+
|
|
45
|
+
**執行內容:**
|
|
46
|
+
- 在 Python 3.10、3.11、3.12 環境下執行測試
|
|
47
|
+
- 安裝依賴並運行 `pytest tests/`
|
|
48
|
+
|
|
49
|
+
### TestPyPI 測試發布 (.github/workflows/test-publish.yml)
|
|
50
|
+
|
|
51
|
+
**觸發條件:**
|
|
52
|
+
- GitHub Pre-release 發布時自動觸發
|
|
53
|
+
- 可手動觸發 (workflow_dispatch)
|
|
54
|
+
|
|
55
|
+
**執行流程:**
|
|
56
|
+
1. 執行完整測試確保品質
|
|
57
|
+
2. 建置套件 (`python -m build`)
|
|
58
|
+
3. 發布到 **TestPyPI**
|
|
59
|
+
4. 驗證發布成功
|
|
60
|
+
5. 測試安裝功能
|
|
61
|
+
6. 自動在 Release 中添加測試報告留言
|
|
62
|
+
|
|
63
|
+
### PyPI 正式發布 (.github/workflows/publish.yml)
|
|
64
|
+
|
|
65
|
+
**觸發條件:**
|
|
66
|
+
- GitHub Release 正式發布時自動觸發
|
|
67
|
+
- 可手動觸發 (workflow_dispatch)
|
|
68
|
+
|
|
69
|
+
**執行流程:**
|
|
70
|
+
1. 執行完整測試確保品質
|
|
71
|
+
2. 建置套件 (`python -m build`)
|
|
72
|
+
3. 發布到 **PyPI**
|
|
73
|
+
4. 驗證發布成功
|
|
74
|
+
5. 自動在 Release 中添加發布報告留言
|
|
75
|
+
|
|
76
|
+
## 發布新版本流程
|
|
77
|
+
|
|
78
|
+
### 方法 1: 通過 GitHub Release(推薦)
|
|
79
|
+
|
|
80
|
+
#### 步驟 1: 測試發佈(TestPyPI)
|
|
81
|
+
|
|
82
|
+
1. **提交代碼變更**
|
|
83
|
+
```bash
|
|
84
|
+
git add .
|
|
85
|
+
git commit -m "feat: add new feature" # 或 "fix: resolve bug" 或 "BREAKING CHANGE: ..."
|
|
86
|
+
git push origin main
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
2. **建立 Git Tag**
|
|
90
|
+
```bash
|
|
91
|
+
# 建立版本標籤(例如:v0.2.0)
|
|
92
|
+
git tag v0.2.0
|
|
93
|
+
git push origin v0.2.0
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
3. **建立 Pre-release**
|
|
97
|
+
- 前往 GitHub Repository → **Releases** → **Create a new release**
|
|
98
|
+
- Tag version: 選擇剛才建立的 tag(例如:`v0.2.0`)
|
|
99
|
+
- Release title: `Version 0.2.0 Release Candidate`
|
|
100
|
+
- 描述更新內容
|
|
101
|
+
- ✅ **勾選 "Set as a pre-release"**
|
|
102
|
+
- 點選 **Publish release**
|
|
103
|
+
|
|
104
|
+
4. **自動測試發布**
|
|
105
|
+
- GitHub Actions 會自動觸發
|
|
106
|
+
- 執行測試 → 建置 → 發布到 **TestPyPI** → 驗證發布 → 測試安裝
|
|
107
|
+
- 可在 https://test.pypi.org/project/redshift-comment-mcp/ 查看
|
|
108
|
+
|
|
109
|
+
#### 📊 如何確認 TestPyPI 發布成功
|
|
110
|
+
|
|
111
|
+
**方法 1: Release 留言(最直觀)**
|
|
112
|
+
1. 前往你的 Pre-release 頁面
|
|
113
|
+
2. 查看自動生成的留言,包含:
|
|
114
|
+
- ✅ 發布狀態
|
|
115
|
+
- 🔗 TestPyPI 連結
|
|
116
|
+
- 📥 測試安裝指令
|
|
117
|
+
|
|
118
|
+
**方法 2: GitHub Actions Summary**
|
|
119
|
+
1. 前往 **Actions** 頁面
|
|
120
|
+
2. 點選最新的 "Test Publish to TestPyPI" workflow run
|
|
121
|
+
3. 查看 **Summary** 區域的 "TestPyPI 發布報告"
|
|
122
|
+
4. 確認狀態顯示 ✅ 成功
|
|
123
|
+
|
|
124
|
+
**方法 3: Actions 日誌詳細檢查**
|
|
125
|
+
1. 在 workflow run 中點選 **test-publish** job
|
|
126
|
+
2. 檢查各個步驟的狀態:
|
|
127
|
+
- ✅ "Publish to TestPyPI" - 上傳成功
|
|
128
|
+
- ✅ "Verify TestPyPI publication" - 確認可下載
|
|
129
|
+
- ✅ "Test installation from TestPyPI" - 安裝測試通過
|
|
130
|
+
- ✅ "Create Test Report" - 生成報告
|
|
131
|
+
|
|
132
|
+
**方法 4: 手動確認**
|
|
133
|
+
```bash
|
|
134
|
+
# 直接查看 TestPyPI 網頁
|
|
135
|
+
https://test.pypi.org/project/redshift-comment-mcp/
|
|
136
|
+
|
|
137
|
+
# 或使用 API 檢查
|
|
138
|
+
curl -s "https://test.pypi.org/pypi/redshift-comment-mcp/json" | jq '.releases | keys'
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
5. **驗證 TestPyPI 套件**
|
|
142
|
+
```bash
|
|
143
|
+
# 從 TestPyPI 安裝測試
|
|
144
|
+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ redshift-comment-mcp==0.1.1
|
|
145
|
+
|
|
146
|
+
# 測試功能是否正常
|
|
147
|
+
redshift-comment-mcp --help
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
#### 步驟 2: 正式發佈(PyPI)
|
|
151
|
+
|
|
152
|
+
6. **建立正式 Release**
|
|
153
|
+
- 前往之前建立的 Pre-release
|
|
154
|
+
- 點選 **Edit release**
|
|
155
|
+
- ❌ **取消勾選 "Set as a pre-release"**
|
|
156
|
+
- Tag version 保持不變: `v0.2.0`(不需要修改)
|
|
157
|
+
- 點選 **Update release**
|
|
158
|
+
|
|
159
|
+
7. **自動正式發布**
|
|
160
|
+
- GitHub Actions 會自動觸發
|
|
161
|
+
- 執行測試 → 建置 → 發布到 **PyPI**
|
|
162
|
+
- 可在 https://pypi.org/project/redshift-comment-mcp/ 查看
|
|
163
|
+
|
|
164
|
+
### 方法 2: 手動觸發
|
|
165
|
+
|
|
166
|
+
1. 前往 **Actions** → **Publish to PyPI**
|
|
167
|
+
2. 點選 **Run workflow**
|
|
168
|
+
3. 選擇分支並執行
|
|
169
|
+
|
|
170
|
+
## 監控發布狀態
|
|
171
|
+
|
|
172
|
+
1. 前往 **Actions** 頁面查看工作流程狀態
|
|
173
|
+
2. 點選具體的 workflow run 查看詳細日誌
|
|
174
|
+
3. 發布成功後,可在 [PyPI](https://pypi.org/project/redshift-comment-mcp/) 確認新版本
|
|
175
|
+
|
|
176
|
+
## 故障排除
|
|
177
|
+
|
|
178
|
+
### 常見問題
|
|
179
|
+
|
|
180
|
+
1. **PyPI API Token 錯誤**
|
|
181
|
+
- 確認 Secret 名稱是 `PYPI_API_TOKEN`
|
|
182
|
+
- 確認 Token 有效且有權限
|
|
183
|
+
|
|
184
|
+
2. **測試失敗**
|
|
185
|
+
- 檢查測試程式碼是否有問題
|
|
186
|
+
- 確保所有依賴都正確安裝
|
|
187
|
+
|
|
188
|
+
3. **建置失敗**
|
|
189
|
+
- 檢查 `pyproject.toml` 設定是否正確
|
|
190
|
+
- 確認檔案結構完整
|
|
191
|
+
|
|
192
|
+
### 查看日誌
|
|
193
|
+
|
|
194
|
+
點選失敗的 Action 查看詳細錯誤訊息,通常會指出具體問題所在。
|
|
195
|
+
|
|
196
|
+
## 版本號自動管理
|
|
197
|
+
|
|
198
|
+
本專案使用 **setuptools-scm** 進行自動版本管理,版本號基於 Git 標籤自動生成。
|
|
199
|
+
|
|
200
|
+
### 版本號規則
|
|
201
|
+
|
|
202
|
+
- **正式版本**:基於 Git tag(例如:`v0.2.0` → 版本 `0.2.0`)
|
|
203
|
+
- **開發版本**:自動生成(例如:`0.2.1.dev3+g1234567`)
|
|
204
|
+
- **格式**:遵循 [語意化版本](https://semver.org/lang/zh-TW/) `MAJOR.MINOR.PATCH`
|
|
205
|
+
|
|
206
|
+
### 版本類型建議
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
# Bug 修復(PATCH:0.1.0 → 0.1.1)
|
|
210
|
+
git tag v0.1.1
|
|
211
|
+
|
|
212
|
+
# 新功能(MINOR:0.1.1 → 0.2.0)
|
|
213
|
+
git tag v0.2.0
|
|
214
|
+
|
|
215
|
+
# 重大變更(MAJOR:0.2.0 → 1.0.0)
|
|
216
|
+
git tag v1.0.0
|
|
217
|
+
|
|
218
|
+
# 預發布版本
|
|
219
|
+
git tag v0.2.0-rc1
|
|
220
|
+
git tag v0.2.0-beta1
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### 檢查當前版本
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
# 安裝 setuptools-scm
|
|
227
|
+
pip install setuptools-scm
|
|
228
|
+
|
|
229
|
+
# 查看當前版本
|
|
230
|
+
python -c "from setuptools_scm import get_version; print(get_version())"
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### 優點
|
|
234
|
+
|
|
235
|
+
- ✅ **自動化**:無需手動更新 `pyproject.toml` 中的版本號
|
|
236
|
+
- ✅ **同步**:版本號與 Git 歷史完全同步
|
|
237
|
+
- ✅ **開發版本**:自動生成開發版本號,便於測試
|
|
238
|
+
- ✅ **防錯**:避免忘記更新版本號的問題
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch: # 允許手動觸發
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
19
|
+
uses: actions/setup-python@v4
|
|
20
|
+
with:
|
|
21
|
+
python-version: ${{ matrix.python-version }}
|
|
22
|
+
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: |
|
|
25
|
+
python -m pip install --upgrade pip
|
|
26
|
+
pip install -e ".[dev]"
|
|
27
|
+
|
|
28
|
+
- name: Run tests
|
|
29
|
+
run: |
|
|
30
|
+
pytest tests/ -v
|
|
31
|
+
|
|
32
|
+
publish:
|
|
33
|
+
needs: test
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v4
|
|
38
|
+
|
|
39
|
+
- name: Set up Python
|
|
40
|
+
uses: actions/setup-python@v4
|
|
41
|
+
with:
|
|
42
|
+
python-version: "3.10"
|
|
43
|
+
|
|
44
|
+
- name: Install build tools
|
|
45
|
+
run: |
|
|
46
|
+
python -m pip install --upgrade pip
|
|
47
|
+
pip install build twine
|
|
48
|
+
|
|
49
|
+
- name: Build package
|
|
50
|
+
run: python -m build
|
|
51
|
+
|
|
52
|
+
- name: Get package version
|
|
53
|
+
id: get_version
|
|
54
|
+
run: |
|
|
55
|
+
pip install setuptools-scm
|
|
56
|
+
VERSION=$(python -c "from setuptools_scm import get_version; print(get_version())")
|
|
57
|
+
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
58
|
+
echo "📋 Package version: $VERSION"
|
|
59
|
+
|
|
60
|
+
- name: Publish to PyPI
|
|
61
|
+
env:
|
|
62
|
+
TWINE_USERNAME: __token__
|
|
63
|
+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
|
|
64
|
+
run: |
|
|
65
|
+
echo "🚀 Publishing to PyPI..."
|
|
66
|
+
twine upload dist/* --verbose
|
|
67
|
+
echo "✅ Published to PyPI successfully!"
|
|
68
|
+
|
|
69
|
+
- name: Verify PyPI publication
|
|
70
|
+
run: |
|
|
71
|
+
echo "🔍 Verifying publication on PyPI..."
|
|
72
|
+
PACKAGE_NAME="redshift-comment-mcp"
|
|
73
|
+
VERSION="${{ steps.get_version.outputs.version }}"
|
|
74
|
+
|
|
75
|
+
# 等待 PyPI 更新
|
|
76
|
+
sleep 30
|
|
77
|
+
|
|
78
|
+
# 檢查套件是否存在於 PyPI
|
|
79
|
+
for i in {1..5};
|
|
80
|
+
do
|
|
81
|
+
echo "⏳ Attempt $i/5: Checking PyPI availability..."
|
|
82
|
+
if curl -f -s "https://pypi.org/pypi/$PACKAGE_NAME/$VERSION/json" > /dev/null;
|
|
83
|
+
then
|
|
84
|
+
echo "✅ Package $PACKAGE_NAME version $VERSION is available on PyPI!"
|
|
85
|
+
echo "🔗 PyPI URL: https://pypi.org/project/$PACKAGE_NAME/$VERSION/"
|
|
86
|
+
break
|
|
87
|
+
else
|
|
88
|
+
echo "⏳ Not yet available, waiting 30 seconds..."
|
|
89
|
+
sleep 30
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
if [ $i -eq 5 ];
|
|
93
|
+
then
|
|
94
|
+
echo "❌ Package not found on PyPI after 5 attempts"
|
|
95
|
+
exit 1
|
|
96
|
+
fi
|
|
97
|
+
done
|
|
98
|
+
|
|
99
|
+
- name: Create Release Report
|
|
100
|
+
if: always()
|
|
101
|
+
run: |
|
|
102
|
+
echo "## 🎉 PyPI Release Report" >> $GITHUB_STEP_SUMMARY
|
|
103
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
104
|
+
echo "- **Package Name**: redshift-comment-mcp" >> $GITHUB_STEP_SUMMARY
|
|
105
|
+
echo "- **Version**: ${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
|
|
106
|
+
echo "- **PyPI URL**: https://pypi.org/project/redshift-comment-mcp/${{ steps.get_version.outputs.version }}/" >> $GITHUB_STEP_SUMMARY
|
|
107
|
+
echo "- **Status**: ${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}" >> $GITHUB_STEP_SUMMARY
|
|
108
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
109
|
+
echo "### 📥 Installation Command" >> $GITHUB_STEP_SUMMARY
|
|
110
|
+
echo '```bash' >> $GITHUB_STEP_SUMMARY
|
|
111
|
+
echo "pip install redshift-comment-mcp==${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
|
|
112
|
+
echo '```' >> $GITHUB_STEP_SUMMARY
|
|
113
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
114
|
+
echo "### 🔄 Upgrade Command" >> $GITHUB_STEP_SUMMARY
|
|
115
|
+
echo '```bash' >> $GITHUB_STEP_SUMMARY
|
|
116
|
+
echo "pip install --upgrade redshift-comment-mcp" >> $GITHUB_STEP_SUMMARY
|
|
117
|
+
echo '```'
|
|
118
|
+
|
|
119
|
+
- name: Add comment to release
|
|
120
|
+
if: github.event_name == 'release' && success()
|
|
121
|
+
uses: actions/github-script@v6
|
|
122
|
+
with:
|
|
123
|
+
script: |
|
|
124
|
+
const version = '${{ steps.get_version.outputs.version }}';
|
|
125
|
+
const pypiUrl = `https://pypi.org/project/redshift-comment-mcp/${version}/`;
|
|
126
|
+
const installCmd = `pip install redshift-comment-mcp==${version}`;
|
|
127
|
+
const upgradeCmd = `pip install --upgrade redshift-comment-mcp`;
|
|
128
|
+
|
|
129
|
+
const body = '## 🚀 PyPI 發布成功!\n\n' +
|
|
130
|
+
'**版本**: ' + version + '\n' +
|
|
131
|
+
'**PyPI 頁面**: ' + pypiUrl + '\n\n' +
|
|
132
|
+
'### 📥 安裝指令\n' +
|
|
133
|
+
'```bash\n' +
|
|
134
|
+
installCmd + '\n' +
|
|
135
|
+
'```\n\n' +
|
|
136
|
+
'### 🔄 升級指令\n' +
|
|
137
|
+
'```bash\n' +
|
|
138
|
+
upgradeCmd + '\n' +
|
|
139
|
+
'```\n\n' +
|
|
140
|
+
'### 📚 使用指南\n' +
|
|
141
|
+
'查看 [README.md](https://github.com/' + context.repo.owner + '/' + context.repo.repo + '#readme) 了解詳細的使用方式。\n\n' +
|
|
142
|
+
'---\n' +
|
|
143
|
+
'🤖 *此訊息由 GitHub Actions 自動生成*';
|
|
144
|
+
|
|
145
|
+
if (context.payload.release.discussion) {
|
|
146
|
+
await github.rest.issues.createComment({
|
|
147
|
+
owner: context.repo.owner,
|
|
148
|
+
repo: context.repo.repo,
|
|
149
|
+
issue_number: context.payload.release.discussion.number,
|
|
150
|
+
body: body
|
|
151
|
+
});
|
|
152
|
+
} else {
|
|
153
|
+
console.log("No associated discussion found for this release. Skipping comment.");
|
|
154
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
name: Test Publish to TestPyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [prereleased]
|
|
6
|
+
workflow_dispatch: # 允許手動觸發
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
19
|
+
uses: actions/setup-python@v4
|
|
20
|
+
with:
|
|
21
|
+
python-version: ${{ matrix.python-version }}
|
|
22
|
+
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: |
|
|
25
|
+
python -m pip install --upgrade pip
|
|
26
|
+
pip install -e ".[dev]"
|
|
27
|
+
|
|
28
|
+
- name: Run tests
|
|
29
|
+
run: |
|
|
30
|
+
pytest tests/ -v
|
|
31
|
+
|
|
32
|
+
test-publish:
|
|
33
|
+
needs: test
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v4
|
|
38
|
+
|
|
39
|
+
- name: Set up Python
|
|
40
|
+
uses: actions/setup-python@v4
|
|
41
|
+
with:
|
|
42
|
+
python-version: "3.10"
|
|
43
|
+
|
|
44
|
+
- name: Install build tools
|
|
45
|
+
run: |
|
|
46
|
+
python -m pip install --upgrade pip
|
|
47
|
+
pip install build twine requests
|
|
48
|
+
|
|
49
|
+
- name: Build package
|
|
50
|
+
run: python -m build
|
|
51
|
+
|
|
52
|
+
- name: Get package version
|
|
53
|
+
id: get_version
|
|
54
|
+
run: |
|
|
55
|
+
pip install setuptools-scm
|
|
56
|
+
VERSION=$(python -c "from setuptools_scm import get_version; print(get_version())")
|
|
57
|
+
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
58
|
+
echo "📋 Package version: $VERSION"
|
|
59
|
+
|
|
60
|
+
- name: Publish to TestPyPI
|
|
61
|
+
env:
|
|
62
|
+
TWINE_USERNAME: __token__
|
|
63
|
+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
|
|
64
|
+
run: |
|
|
65
|
+
echo "📦 Publishing to TestPyPI..."
|
|
66
|
+
twine upload --repository testpypi dist/* --verbose
|
|
67
|
+
echo "✅ Published to TestPyPI successfully!"
|
|
68
|
+
|
|
69
|
+
- name: Verify TestPyPI publication
|
|
70
|
+
run: |
|
|
71
|
+
echo "🔍 Verifying publication on TestPyPI..."
|
|
72
|
+
PACKAGE_NAME="redshift-comment-mcp"
|
|
73
|
+
VERSION="${{ steps.get_version.outputs.version }}"
|
|
74
|
+
|
|
75
|
+
# 等待 TestPyPI 更新(通常需要幾分鐘)
|
|
76
|
+
sleep 30
|
|
77
|
+
|
|
78
|
+
# 檢查套件是否存在於 TestPyPI
|
|
79
|
+
for i in {1..5};
|
|
80
|
+
do
|
|
81
|
+
echo "⏳ Attempt $i/5: Checking TestPyPI availability..."
|
|
82
|
+
if curl -f -s "https://test.pypi.org/pypi/$PACKAGE_NAME/$VERSION/json" > /dev/null;
|
|
83
|
+
then
|
|
84
|
+
echo "✅ Package $PACKAGE_NAME version $VERSION is available on TestPyPI!"
|
|
85
|
+
echo "🔗 TestPyPI URL: https://test.pypi.org/project/$PACKAGE_NAME/$VERSION/"
|
|
86
|
+
break
|
|
87
|
+
else
|
|
88
|
+
echo "⏳ Not yet available, waiting 30 seconds..."
|
|
89
|
+
sleep 30
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
if [ $i -eq 5 ];
|
|
93
|
+
then
|
|
94
|
+
echo "❌ Package not found on TestPyPI after 5 attempts"
|
|
95
|
+
exit 1
|
|
96
|
+
fi
|
|
97
|
+
done
|
|
98
|
+
|
|
99
|
+
- name: Test installation from TestPyPI
|
|
100
|
+
run: |
|
|
101
|
+
echo "🧪 Testing installation from TestPyPI..."
|
|
102
|
+
PACKAGE_NAME="redshift-comment-mcp"
|
|
103
|
+
VERSION="${{ steps.get_version.outputs.version }}"
|
|
104
|
+
|
|
105
|
+
# 建立新的虛擬環境進行測試
|
|
106
|
+
python -m venv test_env
|
|
107
|
+
source test_env/bin/activate
|
|
108
|
+
|
|
109
|
+
# 從 TestPyPI 安裝
|
|
110
|
+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ "$PACKAGE_NAME==$VERSION"
|
|
111
|
+
|
|
112
|
+
# 測試命令是否可用
|
|
113
|
+
redshift-comment-mcp --help
|
|
114
|
+
|
|
115
|
+
echo "✅ Installation test passed!"
|
|
116
|
+
|
|
117
|
+
- name: Create Test Report
|
|
118
|
+
if: always()
|
|
119
|
+
run: |
|
|
120
|
+
echo "## 📊 TestPyPI Publish Report" >> $GITHUB_STEP_SUMMARY
|
|
121
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
122
|
+
echo "- **Package Name**: redshift-comment-mcp" >> $GITHUB_STEP_SUMMARY
|
|
123
|
+
echo "- **Version**: ${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
|
|
124
|
+
echo "- **TestPyPI URL**: https://test.pypi.org/project/redshift-comment-mcp/${{ steps.get_version.outputs.version }}/" >> $GITHUB_STEP_SUMMARY
|
|
125
|
+
echo "- **Status**: ${{ job.status == 'success' && '✅ Success' || '❌ Failed' }}" >> $GITHUB_STEP_SUMMARY
|
|
126
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
127
|
+
echo "### 📥 Test Installation Command" >> $GITHUB_STEP_SUMMARY
|
|
128
|
+
echo '```bash' >> $GITHUB_STEP_SUMMARY
|
|
129
|
+
echo "pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ redshift-comment-mcp==${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
|
|
130
|
+
echo '```' >> $GITHUB_STEP_SUMMARY
|
|
131
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
132
|
+
echo "### ⚠️ Notes" >> $GITHUB_STEP_SUMMARY
|
|
133
|
+
echo "- After successful testing, please convert the Pre-release to a formal Release to trigger PyPI publishing." >> $GITHUB_STEP_SUMMARY
|
|
134
|
+
echo "- Packages on TestPyPI are for testing only. Please use the official PyPI for production installations." >> $GITHUB_STEP_SUMMARY
|
|
135
|
+
|
|
136
|
+
- name: Add comment to release
|
|
137
|
+
if: github.event_name == 'release' && success()
|
|
138
|
+
uses: actions/github-script@v6
|
|
139
|
+
with:
|
|
140
|
+
script: |
|
|
141
|
+
const version = '${{ steps.get_version.outputs.version }}';
|
|
142
|
+
const testPypiUrl = `https://test.pypi.org/project/redshift-comment-mcp/${version}/`;
|
|
143
|
+
const installCmd = `pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ redshift-comment-mcp==${version}`;
|
|
144
|
+
|
|
145
|
+
const body = '## 🎉 TestPyPI 發布成功!\n\n' +
|
|
146
|
+
'**版本**: ' + version + '\n' +
|
|
147
|
+
'**TestPyPI 頁面**: ' + testPypiUrl + '\n\n' +
|
|
148
|
+
'### 📥 測試安裝\n' +
|
|
149
|
+
'```bash\n' +
|
|
150
|
+
installCmd + '\n' +
|
|
151
|
+
'```\n\n' +
|
|
152
|
+
'### 🔄 下一步\n' +
|
|
153
|
+
'如果測試無誤,請將此 Pre-release 轉為正式 Release 以觸發 PyPI 發布。\n\n' +
|
|
154
|
+
'---' +
|
|
155
|
+
'🤖 *此訊息由 GitHub Actions 自動生成*';
|
|
156
|
+
|
|
157
|
+
if (context.payload.release.discussion) {
|
|
158
|
+
await github.rest.issues.createComment({
|
|
159
|
+
owner: context.repo.owner,
|
|
160
|
+
repo: context.repo.repo,
|
|
161
|
+
issue_number: context.payload.release.discussion.number,
|
|
162
|
+
body: body
|
|
163
|
+
});
|
|
164
|
+
} else {
|
|
165
|
+
console.log("No associated discussion found for this release. Skipping comment.");
|
|
166
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main, develop ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main, develop ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
20
|
+
uses: actions/setup-python@v4
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: |
|
|
26
|
+
python -m pip install --upgrade pip
|
|
27
|
+
pip install -e ".[dev]"
|
|
28
|
+
|
|
29
|
+
- name: Run tests
|
|
30
|
+
run: |
|
|
31
|
+
pytest tests/ -v --tb=short
|
|
32
|
+
|
|
33
|
+
- name: Run linting (if available)
|
|
34
|
+
run: |
|
|
35
|
+
# 如果有 linting 工具可以在這裡加入
|
|
36
|
+
echo "Linting skipped - add tools like ruff, black, etc. if needed"
|
|
37
|
+
continue-on-error: true
|