code.gitea.io/gitea@v1.22.3/docs/content/usage/packages/pub.en-us.md (about)

     1  ---
     2  date: "2022-07-31T00:00:00+00:00"
     3  title: "Pub Package Registry"
     4  slug: "pub"
     5  sidebar_position: 90
     6  draft: false
     7  toc: false
     8  menu:
     9    sidebar:
    10      parent: "packages"
    11      name: "Pub"
    12      sidebar_position: 90
    13      identifier: "pub"
    14  ---
    15  
    16  # Pub Package Registry
    17  
    18  Publish [Pub](https://dart.dev/guides/packages) packages for your user or organization.
    19  
    20  ## Requirements
    21  
    22  To work with the Pub package registry, you need to use the tools [dart](https://dart.dev/tools/dart-tool) and/or [flutter](https://docs.flutter.dev/reference/flutter-cli).
    23  
    24  The following examples use dart.
    25  
    26  ## Configuring the package registry
    27  
    28  To register the package registry and provide credentials, execute:
    29  
    30  ```shell
    31  dart pub token add https://gitea.example.com/api/packages/{owner}/pub
    32  ```
    33  
    34  | Placeholder  | Description |
    35  | ------------ | ----------- |
    36  | `owner`      | The owner of the package. |
    37  
    38  You need to provide your [personal access token](development/api-usage.md#authentication).
    39  
    40  ## Publish a package
    41  
    42  To publish a package, edit the `pubspec.yaml` and add the following line:
    43  
    44  ```yaml
    45  publish_to: https://gitea.example.com/api/packages/{owner}/pub
    46  ```
    47  
    48  | Placeholder  | Description |
    49  | ------------ | ----------- |
    50  | `owner`      | The owner of the package. |
    51  
    52  Now you can publish the package by running the following command:
    53  
    54  ```shell
    55  dart pub publish
    56  ```
    57  
    58  You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
    59  
    60  ## Install a package
    61  
    62  To install a Pub package from the package registry, execute the following command:
    63  
    64  ```shell
    65  dart pub add {package_name} --hosted-url=https://gitea.example.com/api/packages/{owner}/pub/
    66  ```
    67  
    68  | Parameter         | Description |
    69  | ----------------- | ----------- |
    70  | `owner`           | The owner of the package. |
    71  | `package_name`    | The package name. |
    72  
    73  For example:
    74  
    75  ```shell
    76  # use latest version
    77  dart pub add mypackage --hosted-url=https://gitea.example.com/api/packages/testuser/pub/
    78  # specify version
    79  dart pub add mypackage:1.0.8 --hosted-url=https://gitea.example.com/api/packages/testuser/pub/
    80  ```