1
1
mirror of https://github.com/go-gitea/gitea synced 2024-06-25 04:35:48 +00:00
gitea/docs/content/usage/packages/swift.zh-cn.md
John Olheiser bd4c7ce578
Docusaurus-ify (#26051)
This PR cleans up the docs in a way to make them simpler to ingest by
our [docs repo](https://gitea.com/gitea/gitea-docusaurus).

1. It includes all of the sed invocations our ingestion did, removing
the need to do it at build time.
2. It replaces the shortcode variable replacement method with
`@variable@` style, simply for easier sed invocations when required.
3. It removes unused files and moves the docs up a level as cleanup.

---------

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-07-26 04:53:13 +00:00

4.2 KiB
Raw Blame History

date title slug sidebar_position draft toc menu
2023-01-10T00:00:00+00:00 Swift 软件包注册表 swift 95 false false
sidebar
parent name sidebar_position identifier
packages Swift 95 swift

Swift 软件包注册表

为您的用户或组织发布 Swift 软件包。

要求

要使用 Swift 软件包注册表,您需要使用 swift 消费软件包,并使用 HTTP 客户端(如 curl)发布软件包。

配置软件包注册表

要注册软件包注册表并提供凭据,请执行以下命令:

swift package-registry set https://gitea.example.com/api/packages/{owner}/swift -login {username} -password {password}
占位符 描述
owner 软件包的所有者。
username 您的 Gitea 用户名。
password 您的 Gitea 密码。如果您使用两步验证或 OAuth请使用个人访问令牌代替密码。

登录是可选的,只有在软件包注册表是私有的情况下才需要。

发布软件包

首先,您需要打包软件包的内容:

swift package archive-source

要发布软件包,请执行一个带有软件包内容的 HTTP PUT 请求,将内容放在请求正文中。

curl -X PUT --user {username}:{password} \
	 -H "Accept: application/vnd.swift.registry.v1+json" \
	 -F source-archive=@/path/to/package.zip \
	 -F metadata={metadata} \
	 https://gitea.example.com/api/packages/{owner}/swift/{scope}/{name}/{version}
占位符 描述
username 您的 Gitea 用户名。
password 您的 Gitea 密码。如果您使用两步验证或 OAuth请使用个人访问令牌代替密码。
owner 软件包的所有者。
scope 软件包的作用域。
name 软件包的名称。
version 软件包的版本。
metadata (可选)软件包的元数据。以 JSON 编码的子集,格式参考 https://schema.org/SoftwareSourceCode

如果已经存在相同名称和版本的软件包,则无法发布软件包。您必须首先删除现有的软件包。

安装软件包

要从软件包注册表安装 Swift 软件包,请将其添加到 Package.swift 文件的依赖项列表中:

dependencies: [
	.package(id: "{scope}.{name}", from:"{version}")
]
参数 描述
scope 软件包的作用域
name 软件包的名称
version 软件包的版本

之后,执行以下命令来安装它:

swift package resolve