kcl-lang.io/kpm@v0.8.7-0.20240520061008-9fc4c5efc8c7/docs/publish_pkg_to_ah.md (about) 1 # Publish KCL Package 2 3 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). 4 5 ## Prerequisites 6 7 - Install [kpm](https://kcl-lang.io/docs/user_docs/guides/package-management/installation/) 8 - Install [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) 9 - [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) 10 11 ## Code Repository 12 13 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. 14 15 ## Quick Start 16 In the next section, we will show you how to publish your package with a `helloworld` example. 17 18 ### 1. Clone the code repository 19 20 First, you need to clone the repository 21 22 ``` 23 git clone https://github.com/kcl-lang/artifacthub --depth=1 24 ``` 25 26 ### 2. Create a branch for your package 27 28 We recommend that your branch name be: `publish-pkg-<pkg_name>`, `<pkg_name>` is the name of your package. 29 30 Take the package `helloworld` as an example 31 32 Enter the artifacthub directory you downloaded 33 ``` 34 cd artifacthub 35 ``` 36 37 Create a branch `publish-pkg-helloworld` for the package `helloworld` 38 ``` 39 git checkout -b publish-pkg-helloworld 40 ``` 41 42 ### 3. Add your KCL package 43 44 You need to move your package to the current directory. In our example, we use the `kpm init` command to create the package `helloworld` 45 46 ``` 47 kpm init helloworld 48 ``` 49 50 You can add a `README.md` file to the root directory of the package to display on the homepage of AH. 51 ``` 52 echo "## Introduction" >> helloworld/README.md 53 echo "This is a kcl package named helloworld." >> helloworld/README.md 54 ``` 55 56 ### 4. Commit your package 57 58 You can use the following command to commit your package 59 60 Use `git add .` command to add your package to the staging area of git 61 62 ``` 63 git add . 64 ``` 65 66 Use `git commit -s` command to commit your package, we recommend that your commit message follow the format "publish package <pkg_name>". 67 ``` 68 git commit -m"publish package helloworld" -s 69 ``` 70 71 Use `git push` command to submit your package to your branch `publish-pkg-<pkg_name>` 72 73 ``` 74 git push 75 ``` 76 77 ### 5. Submit a PR 78 79 Finally, you need to submit a PR to the main branch of the repository with your branch `publish-pkg-<pkg_name>`. 80 81 - [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)