Skip to content

Commit

Permalink
feat: 描述如何发布 Python SDK
Browse files Browse the repository at this point in the history
Signed-off-by: Ke Jie <[email protected]>
  • Loading branch information
chzealot committed Sep 18, 2023
1 parent aa6c49a commit 6ec4da9
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/contrib/ci/nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 中实现了自动化构建与发布。

Expand Down Expand Up @@ -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)
49 changes: 49 additions & 0 deletions docs/contrib/ci/python.md
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 6ec4da9

Please sign in to comment.