From 6ec4da96391960860b44d6ef5241afcf6a2deeec Mon Sep 17 00:00:00 2001 From: Ke Jie Date: Mon, 18 Sep 2023 22:29:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8F=8F=E8=BF=B0=E5=A6=82=E4=BD=95?= =?UTF-8?q?=E5=8F=91=E5=B8=83=20Python=20SDK?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ke Jie --- docs/contrib/ci/nodejs.md | 3 ++- docs/contrib/ci/python.md | 49 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 docs/contrib/ci/python.md diff --git a/docs/contrib/ci/nodejs.md b/docs/contrib/ci/nodejs.md index 79859134..19393be8 100644 --- a/docs/contrib/ci/nodejs.md +++ b/docs/contrib/ci/nodejs.md @@ -4,7 +4,7 @@ sidebar_position: 1 # Node.js SDK 发布 -本文介绍如何通过 GitHub Action 自动化发布 dingtalk-stream-sdk-nodejs 这个 SDK。 +本文介绍如何通过 GitHub Action 自动化发布 [dingtalk-stream-sdk-nodejs](https://www.npmjs.com/package/dingtalk-stream-sdk-nodejs) 这个 SDK。 核心思想是通过 GitHub Release 触发 GitHub Action 执行,在 GitHub Action 中实现了自动化构建与发布。 @@ -43,6 +43,7 @@ NPM 发布的 Token,采用钉钉开放平台公共账号创建的 Access Token ## 相关链接 +* [npm 上 dingtalk-stream-sdk-nodejs 首页](https://www.npmjs.com/package/dingtalk-stream-sdk-nodejs) * [GitHub Actions documentation](https://docs.github.com/en/actions) * [Using secrets in GitHub Actions](https://docs.github.com/actions/security-guides/encrypted-secrets) * 该项目的构建脚本为:[.github/workflows/publish.yml](https://github.com/open-dingtalk/dingtalk-stream-sdk-nodejs/blob/main/.github/workflows/publish.yml) \ No newline at end of file diff --git a/docs/contrib/ci/python.md b/docs/contrib/ci/python.md new file mode 100644 index 00000000..f768b9b4 --- /dev/null +++ b/docs/contrib/ci/python.md @@ -0,0 +1,49 @@ +--- +sidebar_position: 2 +--- + +# Python SDK 发布 + +本文介绍如何通过 GitHub Action 自动化发布 [dingtalk-stream](https://pypi.org/project/dingtalk-stream/) 这个 SDK。 + +核心思想是通过 GitHub Release 触发 GitHub Action 执行,在 GitHub Action 中实现了自动化构建与发布。 + +## 步骤说明 + +1. **更新版本号**:按照[规范](intro),确定准备发布的版本号,例如 x.y.z。并将该版本号更新到 `dingtalk_stream/version.py` 的 `VERSION_STRING` 中。 + 1. 建议:提交 Pull request 时候,把 `dingtalk_stream/version.py` 中的版本变更一同提交 +2. **创建 Release**:在[项目首页](https://github.com/open-dingtalk/dingtalk-stream-sdk-python),点击右侧 [Releases](https://github.com/open-dingtalk/dingtalk-stream-sdk-python/releases) 后,点击`Draft a new release`,填写表单完成发布 + 1. 要求:对于常规发布,Release title 中只写版本号,格式为 `vX.Y.Z` + 2. 要求:如果是 Breaking change,需要 title 中备注,格式为 `vX.Y.Z Breaking change` +3. **检查 CI 结果**:完成步骤 2 的 Release 之后,GitHub action 就会自动执行,可以进入 [Actions](https://github.com/open-dingtalk/dingtalk-stream-sdk-python/actions) 中检查构建状态及结果。 + +## 深入理解原理 + +该项目使用了 [GitHub Actions](https://docs.github.com/en/actions) 实现自动化构建与 NPM 发布。对应的构建脚本在 [.github/workflows/publish.yml](https://github.com/open-dingtalk/dingtalk-stream-sdk-python/blob/main/.github/workflows/publish.yml) 中 + +触发条件(通过 GitHub release 触发): +```text +on: + release: + types: [published] +``` + +构建脚本: +```text + run: | + python setup.py sdist bdist_wheel +``` + +PYPI 发布的 Token,采用钉钉开放平台公共账号创建的 Access Token(通过 [GitHub secrets](https://docs.github.com/actions/security-guides/encrypted-secrets) 管理): +```text + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} +``` + +## 相关链接 + +* [PyPI 上 dingtalk-stream 首页](https://pypi.org/project/dingtalk-stream/) +* [GitHub Actions documentation](https://docs.github.com/en/actions) +* [Using secrets in GitHub Actions](https://docs.github.com/actions/security-guides/encrypted-secrets) +* 该项目的构建脚本为:[.github/workflows/publish.yml](https://github.com/open-dingtalk/dingtalk-stream-sdk-python/blob/main/.github/workflows/publish.yml) \ No newline at end of file