mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-30 04:15:45 +08:00
docs(plugin): document auto-release workflow and zh README scaffold (SDK #68)
This commit is contained in:
@@ -20,6 +20,21 @@ Upload your plugin to GitHub, then go to the Release page of your plugin reposit
|
||||
|
||||
<img width="600" src="/images/zh/plugin/dev/dist/github_release.png" />
|
||||
|
||||
## Auto-create Release (GitHub Actions)
|
||||
|
||||
Plugins created by `lbp init` come with a built-in GitHub Actions workflow (`.github/workflows/release.yml`), so you don't have to build and upload manually.
|
||||
|
||||
After pushing your plugin repository to GitHub, whenever you bump the `version` field in `manifest.yaml` and push to the `main` or `master` branch, the workflow will automatically:
|
||||
|
||||
1. Install the `lbp` CLI and run `lbp build` to package the plugin;
|
||||
2. Create a GitHub Release tagged `v<version>` and upload the generated `.lbpkg` file.
|
||||
|
||||
If a Release for that version already exists, the workflow skips it to avoid duplicate publishing. You can also trigger it manually from the repository's Actions page (`workflow_dispatch`).
|
||||
|
||||
<Info title="">
|
||||
The workflow relies on the repository's default `GITHUB_TOKEN` and requires the `contents: write` permission (already declared in the template). Make sure Actions is enabled for the repository, and that the `metadata.author`, `metadata.name`, and `metadata.version` fields in `manifest.yaml` are correct — the Release name and artifact filename are composed from these fields (`<author>-<name>-<version>.lbpkg`).
|
||||
</Info>
|
||||
|
||||
## Install Plugin
|
||||
|
||||
In LangBot's plugin management page, click the top-right corner to select the GitHub installation method.
|
||||
|
||||
@@ -38,7 +38,12 @@ A plugin's directory structure is similar to the following:
|
||||
├── main.py # Plugin main program, listens to plugin lifecycle
|
||||
├── manifest.yaml # Plugin manifest file, describes plugin metadata
|
||||
├── README.md # Plugin documentation file, describes plugin functionality and usage, displayed on the plugin marketplace page
|
||||
└── requirements.txt # Plugin dependencies file
|
||||
├── readme
|
||||
│ └── README_zh_Hans.md # Simplified Chinese documentation, for multi-language docs
|
||||
├── requirements.txt # Plugin dependencies file
|
||||
└── .github
|
||||
└── workflows
|
||||
└── release.yml # GitHub Actions workflow, automatically builds and publishes a Release when the version is bumped
|
||||
```
|
||||
|
||||
The plugin class in main.py is common code for each plugin, initialized when the plugin starts and passed context information (configuration, etc.). You can implement initialization and shutdown logic for the plugin here. The plugin class inherits from `langbot_plugin.api.definition.plugin.BasePlugin` and provides [LangBot Global APIs](/en/plugin/dev/apis/common).
|
||||
|
||||
@@ -20,6 +20,21 @@ lbp build
|
||||
|
||||
<img width="600" src="/images/zh/plugin/dev/dist/github_release.png" />
|
||||
|
||||
## Releaseの自動作成(GitHub Actions)
|
||||
|
||||
`lbp init` で作成されたプラグインには、GitHub Actions ワークフロー(`.github/workflows/release.yml`)が組み込まれているため、手動でビルドしてアップロードする必要はありません。
|
||||
|
||||
プラグインリポジトリを GitHub にプッシュした後、`manifest.yaml` の `version` フィールドを変更して `main` または `master` ブランチにプッシュするたびに、ワークフローが自動的に以下を実行します:
|
||||
|
||||
1. `lbp` CLI をインストールし、`lbp build` を実行してプラグインをパッケージ化;
|
||||
2. `v<version>` をタグとして GitHub Release を作成し、生成された `.lbpkg` ファイルをアップロード。
|
||||
|
||||
該当バージョンの Release が既に存在する場合、ワークフローはスキップして重複公開を回避します。リポジトリの Actions ページから手動でトリガーすることもできます(`workflow_dispatch`)。
|
||||
|
||||
<Info title="">
|
||||
このワークフローはリポジトリのデフォルトの `GITHUB_TOKEN` に依存し、`contents: write` 権限が必要です(テンプレートで宣言済み)。リポジトリの Actions が有効になっていること、`manifest.yaml` の `metadata.author`、`metadata.name`、`metadata.version` フィールドが正しく入力されていることを確認してください。Release 名と成果物のファイル名はこれらのフィールドから構成されます(`<author>-<name>-<version>.lbpkg`)。
|
||||
</Info>
|
||||
|
||||
## プラグインのインストール
|
||||
|
||||
LangBotのプラグイン管理ページで、右上隅をクリックしてGitHubインストール方法を選択します。
|
||||
|
||||
@@ -38,7 +38,12 @@ Plugin Runtimeは、インストールされた各プラグインを自動的に
|
||||
├── main.py # プラグインメインプログラム、プラグインライフサイクルをリッスン
|
||||
├── manifest.yaml # プラグインマニフェストファイル、プラグインメタデータを記述
|
||||
├── README.md # プラグインドキュメントファイル、プラグイン機能と使用方法を記述、プラグインマーケットプレイスページに表示
|
||||
└── requirements.txt # プラグイン依存関係ファイル
|
||||
├── readme
|
||||
│ └── README_zh_Hans.md # 簡体字中国語ドキュメント、多言語ドキュメント用
|
||||
├── requirements.txt # プラグイン依存関係ファイル
|
||||
└── .github
|
||||
└── workflows
|
||||
└── release.yml # GitHub Actions ワークフロー、バージョン変更をプッシュすると自動的にビルドして Release を公開
|
||||
```
|
||||
|
||||
main.pyのプラグインクラスは各プラグインの共通コードで、プラグイン起動時に初期化され、コンテキスト情報(設定など)が渡されます。ここでプラグインの初期化とシャットダウンロジックを実装できます。プラグインクラスは`langbot_plugin.api.definition.plugin.BasePlugin`を継承し、[LangBotグローバルAPI](/en/plugin/dev/apis/common)を提供します。
|
||||
|
||||
@@ -20,6 +20,21 @@ lbp build
|
||||
|
||||
<img width="600" src="/images/zh/plugin/dev/dist/github_release.png" />
|
||||
|
||||
## 自动创建 Release(GitHub Actions)
|
||||
|
||||
自 `lbp init` 创建的插件已内置一个 GitHub Actions 工作流(`.github/workflows/release.yml`),无需手动打包和上传。
|
||||
|
||||
将插件仓库推送到 GitHub 后,每当您修改 `manifest.yaml` 中的 `version` 字段并推送到 `main` 或 `master` 分支时,该工作流会自动:
|
||||
|
||||
1. 安装 `lbp` CLI 并执行 `lbp build` 打包插件;
|
||||
2. 以 `v<version>` 为标签创建一个 GitHub Release,并上传生成的 `.lbpkg` 文件。
|
||||
|
||||
若对应版本号的 Release 已存在,则工作流会跳过,不会重复发布。您也可以在仓库的 Actions 页面手动触发(`workflow_dispatch`)。
|
||||
|
||||
<Info title="">
|
||||
该工作流依赖仓库默认的 `GITHUB_TOKEN`,并需要 `contents: write` 权限(模板已声明)。请确保仓库的 Actions 已启用,且 `manifest.yaml` 中的 `metadata.author`、`metadata.name`、`metadata.version` 字段填写正确——Release 名称与产物文件名均由这些字段拼接而成(`<author>-<name>-<version>.lbpkg`)。
|
||||
</Info>
|
||||
|
||||
## 安装插件
|
||||
|
||||
请在 LangBot 的插件管理页面,点击右上角即可选择 GitHub 安装方式。
|
||||
|
||||
@@ -38,7 +38,12 @@ Plugin Runtime 会自动启动各个已安装的插件,通过 stdio 交互。
|
||||
├── main.py # 插件主程序,监听插件的生命周期
|
||||
├── manifest.yaml # 插件清单文件,描述插件的元信息
|
||||
├── README.md # 插件说明文件,描述插件的功能和使用方法,会被展示在插件市场页面
|
||||
└── requirements.txt # 插件依赖文件
|
||||
├── readme
|
||||
│ └── README_zh_Hans.md # 中文说明文件,用于多语言文档
|
||||
├── requirements.txt # 插件依赖文件
|
||||
└── .github
|
||||
└── workflows
|
||||
└── release.yml # GitHub Actions 工作流,推送版本号变更时自动构建并发布 Release
|
||||
```
|
||||
|
||||
main.py 中的插件类是每个插件通用的代码,在插件被启动时会被初始化,并传入上下文信息(配置信息等)。您可在此实现插件的初始化和关闭时的逻辑。插件类会继承于`langbot_plugin.api.definition.plugin.BasePlugin`,并提供 [LangBot 全局 API](/zh/plugin/dev/apis/common)。
|
||||
|
||||
Reference in New Issue
Block a user