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

     1  ---
     2  date: "2023-01-10T00:00:00+00:00"
     3  title: "Swift Package Registry"
     4  slug: "swift"
     5  sidebar_position: 95
     6  draft: false
     7  toc: false
     8  menu:
     9    sidebar:
    10      parent: "packages"
    11      name: "Swift"
    12      sidebar_position: 95
    13      identifier: "swift"
    14  ---
    15  
    16  # Swift Package Registry
    17  
    18  Publish [Swift](https://www.swift.org/) packages for your user or organization.
    19  
    20  ## Requirements
    21  
    22  To work with the Swift package registry, you need to use [swift](https://www.swift.org/getting-started/) to consume and a HTTP client (like `curl`) to publish packages.
    23  
    24  ## Configuring the package registry
    25  
    26  To register the package registry and provide credentials, execute:
    27  
    28  ```shell
    29  swift package-registry set https://gitea.example.com/api/packages/{owner}/swift
    30  swift package-registry login https://gitea.example.com/api/packages/{owner}/swift --username {username} --password {password}
    31  ```
    32  
    33  | Placeholder  | Description |
    34  | ------------ | ----------- |
    35  | `owner`      | The owner of the package. |
    36  | `username`   | Your Gitea username. |
    37  | `password`   | Your Gitea password. If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. |
    38  
    39  The login is optional and only needed if the package registry is private.
    40  
    41  ## Publish a package
    42  
    43  First you have to pack the contents of your package:
    44  
    45  ```shell
    46  swift package archive-source
    47  ```
    48  
    49  To publish the package perform a HTTP PUT request with the package content in the request body.
    50  
    51  ```shell --user your_username:your_password_or_token \
    52  curl -X PUT --user {username}:{password} \
    53  	 -H "Accept: application/vnd.swift.registry.v1+json" \
    54  	 -F source-archive=@/path/to/package.zip \
    55  	 -F metadata={metadata} \
    56  	 https://gitea.example.com/api/packages/{owner}/swift/{scope}/{name}/{version}
    57  ```
    58  
    59  | Placeholder | Description |
    60  | ----------- | ----------- |
    61  | `username`  | Your Gitea username. |
    62  | `password`  | Your Gitea password. If you are using 2FA or OAuth use a [personal access token](development/api-usage.md#authentication) instead of the password. |
    63  | `owner`     | The owner of the package. |
    64  | `scope`     | The package scope. |
    65  | `name`      | The package name. |
    66  | `version`   | The package version. |
    67  | `metadata`  | (Optional) The metadata of the package. JSON encoded subset of https://schema.org/SoftwareSourceCode |
    68  
    69  You cannot publish a package if a package of the same name and version already exists. You must delete the existing package first.
    70  
    71  The server responds with the following HTTP Status codes.
    72  
    73  | HTTP Status Code  | Meaning |
    74  | ----------------- | ------- |
    75  | `201 Created`     | The package has been published. |
    76  | `400 Bad Request` | The package is invalid. |
    77  | `409 Conflict`    | A package file with the same combination of parameters exists already. |
    78  
    79  ## Install a package
    80  
    81  To install a Swift package from the package registry, add it in the `Package.swift` file dependencies list:
    82  
    83  ```
    84  dependencies: [
    85  	.package(id: "{scope}.{name}", from:"{version}")
    86  ]
    87  ```
    88  
    89  | Parameter   | Description |
    90  | ----------- | ----------- |
    91  | `scope`     | The package scope. |
    92  | `name`      | The package name. |
    93  | `version`   | The package version. |
    94  
    95  Afterwards execute the following command to install it:
    96  
    97  ```shell
    98  swift package resolve
    99  ```