diff --git a/.github/prompts/release.prompt.md b/.github/prompts/release.prompt.md index a92a55d..f213dd9 100644 --- a/.github/prompts/release.prompt.md +++ b/.github/prompts/release.prompt.md @@ -92,17 +92,17 @@ git tag -a vx.y.z -m "Release vx.y.z" git push origin vx.y.z ``` -### 6. 创建 GitHub Release -- 使用 GitHub API 创建 Release -- 标签:`vx.y.z` -- 标题:`Release vx.y.z` 或自定义标题 -- 内容:第 4 步生成的 Release Notes -- 发布后,GitHub Actions 会自动触发 PyPI 发布 - -### 7. 验证发布 +**推送标签后会自动触发**: +1. 构建 Python 包 +2. 发布到 PyPI +3. 创建 GitHub Release(从 CHANGELOG.md 提取发布说明) +4. 上传构建产物(wheel 和 sdist)到 Release + +### 6. 验证发布 - 等待 GitHub Actions 完成(检查 workflow 状态) -- 提供 PyPI 链接:`https://pypi.org/project/hyperliquid-mcp-python/x.y.z/` -- 提供 GitHub Release 链接 +- 验证 PyPI 发布:`https://pypi.org/project/hyperliquid-mcp-python/x.y.z/` +- 验证 GitHub Release:`https://github.com/talkincode/hyperliquid-mcp-python/releases/tag/vx.y.z` +- 确认 Release 包含构建产物附件 ## 注意事项 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2ca4040..2692ed7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,8 +1,9 @@ name: Publish to PyPI on: - release: - types: [published] + push: + tags: + - 'v*.*.*' workflow_dispatch: jobs: @@ -11,7 +12,7 @@ jobs: runs-on: ubuntu-latest permissions: id-token: write - contents: read + contents: write # 需要写权限来创建 Release steps: - uses: actions/checkout@v5 @@ -36,3 +37,34 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.PYPI_API_TOKEN }} + + - name: Extract version from tag + id: get_version + run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + + - name: Generate release notes + id: release_notes + run: | + # 读取 CHANGELOG.md 中当前版本的内容 + VERSION=${{ steps.get_version.outputs.VERSION }} + if [ -f CHANGELOG.md ]; then + # 提取当前版本的变更日志 + awk "/## \[${VERSION}\]/,/## \[/" CHANGELOG.md | sed '$d' > release_notes.md + if [ ! -s release_notes.md ]; then + echo "Release v${VERSION}" > release_notes.md + fi + else + echo "Release v${VERSION}" > release_notes.md + fi + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + name: Release v${{ steps.get_version.outputs.VERSION }} + body_path: release_notes.md + files: | + dist/* + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}