Skip to content

Commit

Permalink
doc: add docs for 'publish kcl package' (#208)
Browse files Browse the repository at this point in the history
* feat: add docs for 'publish kcl package'

Signed-off-by: zongz <[email protected]>

* fix: fix typo

Signed-off-by: zongz <[email protected]>

* feat: add en doc

Signed-off-by: zongz <[email protected]>

* feat: add index on README.md

Signed-off-by: zongz <[email protected]>

---------

Signed-off-by: zongz <[email protected]>
  • Loading branch information
zong-zhe authored Oct 26, 2023
1 parent abc1063 commit dd18da2
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 0 deletions.
1 change: 1 addition & 0 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,4 @@ A: `go install` 默认会将二进制文件安装到 `$GOPATH/bin` 目录下,
- [kpm 命令参考](./docs/command-reference-zh/index.md)
- [kcl.mod: KCL 包清单文件](./docs/kcl_mod-zh.md)
- [如何使用 kpm 通过 github action 来推送您的 kcl 包](./docs/push_by_github_action-zh.md)
- [发布 KCL 包到官方 Registry](./docs/publish_pkg_to_ah-zh.md)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,4 @@ For more information about [OCI registry support](./docs/kpm_oci.md).
- [kpm command reference](./docs/command-reference/index.md)
- [kcl.mod: The KCL package Manifest File](./docs/kcl_mod.md)
- [How to use kpm to push your kcl package by github action](./docs/push_by_github_action.md)
- [How to publish KCL package to official Registry](./docs/publish_pkg_to_ah.md)
83 changes: 83 additions & 0 deletions docs/publish_pkg_to_ah-zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# 发布 KCL 包

接下来,我们将以一个 helloworld 的例子,展示如何快速发布您的包到 kcl-lang 官方的 Registry 中,已经发布的包您可以在 AH (artifacthub.io) 中找到他们。

## 准备工作

- 安装 [kpm](https://kcl-lang.io/zh-CN/docs/user_docs/guides/package-management/installation/)
- 安装 [git](https://git-scm.com/book/zh/v2/%E8%B5%B7%E6%AD%A5-%E5%AE%89%E8%A3%85-Git)
- [注册一个 Github 账户(可选,您需要有一个github的账户)](https://docs.github.com/zh/get-started/signing-up-for-github/signing-up-for-a-new-github-account)

## 代码仓库

注意:如果您希望将您的 KCL 包发布到 kcl-lang 官方的 Registry 中,那么您的 KCL 包的源代码将以开源的形式保存在 [Github 仓库: https://github.com/kcl-lang/artifacthub)](https://github.com/kcl-lang/artifacthub) 中,您需要将您的包的源代码通过 PR 提交到这个仓库中。

## 快速开始
接下来,我们以 KCL 包 `helloworld` 为例,展示一下包的发布过程。

### 1. 下载代码仓库

首先,您需要使用 git 将仓库 https://github.com/kcl-lang/artifacthub下载到您的本地

```
git clone https://github.com/kcl-lang/artifacthub --depth=1
```

### 2. 为您的包创建一个分支

我们推荐您的分支名为:publish-pkg-<pkg_name>, <pkg_name> 为您包的名称。

以包 helloworld 为例

进入您下载的artifacthub目录中
```
cd artifacthub
```
为包 helloworld 创建一个分支 `publish-pkg-helloworld`
```
git checkout -b publish-pkg-helloworld
```

### 3. 添加您的包

您需要将您的包移动到当前目录下,在我们的例子中,我们使用 kpm init 命令创建包 helloworld

```
kpm init helloworld
```

您可以为 helloworld 包增加一个 README.md 文件保存在包的根目录下,用来展示在 AH 的首页中。
```
echo "## Introduction" >> helloworld/README.md
echo "This is a kcl package named helloworld." >> helloworld/README.md
```

### 4. 提交您的包

您可以使用如下命令提交您的包

使用 `git add .` 命令将您的包添加到 git 的暂存区中

```
git add .
```

使用 `git commit -s` 命令提交您的包, 我们推荐您的 commit message 遵循 “publish package <pkg_name>” 的格式。
```
git commit -m"publish package helloworld" -s
```

使用 `git push` 命令将您的包提交到您的分支 publish-pkg-<pkg_name> 中
```
git push
```

### 5. 提交 PR

将您的分支 publish-pkg-<pkg_name> 向仓库的 main 分支提交 PR。

- [如何创建 PR](https://docs.github.com/zh/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request)




81 changes: 81 additions & 0 deletions docs/publish_pkg_to_ah.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Publish KCL Package

In this guide, we will show you how to publish your KCL package to the kcl-lang official registry with a `helloworld` example. You can find the published packages in AH (artifacthub.io).

## Prerequisites

- Install [kpm](https://kcl-lang.io/docs/user_docs/guides/package-management/installation/)
- Install [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- [Register a Github account (optional, you need a github account)](https://docs.github.com/en/get-started/signing-up-for-github/signing-up-for-a-new-github-account)

## Code Repository

NOTE: If you want to publish your KCL package to the kcl-lang official registry, then the source code of your KCL package will be saved in [Github Repo: https://github.com/kcl-lang/artifacthub)](https://github.com/kcl-lang/artifacthub), you need to submit the source code of your package to this repository via PR.

## Quick Start
In the next section, we will show you how to publish your package with a `helloworld` example.

### 1. Clone the code repository

First, you need to clone the repository

```
git clone https://github.com/kcl-lang/artifacthub --depth=1
```

### 2. Create a branch for your package

We recommend that your branch name be: `publish-pkg-<pkg_name>`, `<pkg_name>` is the name of your package.

Take the package `helloworld` as an example

Enter the artifacthub directory you downloaded
```
cd artifacthub
```

Create a branch `publish-pkg-helloworld` for the package `helloworld`
```
git checkout -b publish-pkg-helloworld
```

### 3. Add your KCL package

You need to move your package to the current directory. In our example, we use the `kpm init` command to create the package `helloworld`

```
kpm init helloworld
```

You can add a `README.md` file to the root directory of the package to display on the homepage of AH.
```
echo "## Introduction" >> helloworld/README.md
echo "This is a kcl package named helloworld." >> helloworld/README.md
```

### 4. Commit your package

You can use the following command to commit your package

Use `git add .` command to add your package to the staging area of git

```
git add .
```

Use `git commit -s` command to commit your package, we recommend that your commit message follow the format "publish package <pkg_name>".
```
git commit -m"publish package helloworld" -s
```

Use `git push` command to submit your package to your branch `publish-pkg-<pkg_name>`

```
git push
```

### 5. Submit a PR

Finally, you need to submit a PR to the main branch of the repository with your branch `publish-pkg-<pkg_name>`.

- [How to create PR](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request)

0 comments on commit dd18da2

Please sign in to comment.