github.com/wmuizelaar/kpt@v0.0.0-20221018115725-bd564717b2ed/site/book/03-packages/08-publishing-a-package.md (about)

     1  A kpt package is published as a Git subdirectory containing KRM resources.
     2  Publishing a package is just a normal Git push. This also means that any
     3  existing Git directory of KRM resources is a valid kpt package.
     4  
     5  As an example, let's re-publish the local `wordpress` package to your own repo.
     6  
     7  Start by initializing the the `wordpress` directory as a Git repo if you haven't
     8  already done so:
     9  
    10  ```shell
    11  $ cd wordpress; git init; git add .; git commit -m "My wordpress package"
    12  ```
    13  
    14  Tag the commit:
    15  
    16  ```shell
    17  $ git tag v0.1
    18  ```
    19  
    20  Push the commit which requires you to have access to the repo:
    21  
    22  ```shell
    23  $ git push origin v0.1
    24  ```
    25  
    26  You can then fetch the published package:
    27  
    28  ```shell
    29  $ kpt pkg get <MY_REPO_URL>/@v0.1
    30  ```
    31  
    32  ## Monorepo Versioning
    33  
    34  You may have a Git repo containing multiple packages. kpt provides a tagging
    35  convention to enable packages to be independently versioned.
    36  
    37  For example, let's assume the `wordpress` directory is not at the root of the
    38  repo but instead is in the directory `packages/wordpress`.
    39  
    40  Tag the commit:
    41  
    42  ```shell
    43  $ git tag packages/wordpress/v0.1
    44  ```
    45  
    46  Push the commit:
    47  
    48  ```shell
    49  $ git push origin packages/wordpress/v0.1
    50  ```
    51  
    52  You can then fetch the published package:
    53  
    54  ```shell
    55  $ kpt pkg get <MY_REPO_URL>/packages/wordpress@v0.1
    56  ```
    57  
    58  [tagging]: https://git-scm.com/book/en/v2/Git-Basics-Tagging