包上传

包可以使用fpm publish命令上传到官方注册表。在成功上传后,用户可以搜索该软件包并在他们的项目中使用它。但要注意的是,上传是永久性的。一旦一个软件包被上传,它就不能被删除。如果你想对软件包进行修改,你将不得不创建一个新版本的软件包并上传。

fpm version 0.8.2 and higher is required to upload packages to the registry.

备注

We are currently building and testing the registry. All uploaded packages will be deleted after the testing period (in June 2023)

先决条件

注册

在你上传包裹之前,你需要在官方登记处拥有一个账户。你可以通过访问登记处网站创建一个账户。

命名空间

A package must be uploaded to a given namespace. If you don’t have a namespace yet, you need to create one on the website first. A user can have multiple namespaces and a namespace can accomodate multiple packages.

令牌

After having created a namespace, you will need to generate a token to upload a package to that namespace. You can do this on the website as well. The token is used to authenticate the upload and is linked to your username. Do not share the token with anyone else. The token also expires after a certain amount of time. You can generate a new token after the old one has expired.

版本

一个软件包必须在其清单中指定一个有效的semver版本。

你可以在发布前通过运行fpm publish --show-package-version来检查软件包的版本。

许可证

一个软件包必须在其清单中指定一个有效的SPDX许可证。

上传权限

Users can upload a package to a namespace if they are either an admin or maintainer of the namespace or a maintainer of the package. Namespace admins can grant namespace admin and maintainer rights to other users. Users can be granted maintainer rights for individual packages by namespace admins, maintainers, and package maintainers.

上传

fpm will create a tarball and upload the package to the registry with all the requirements being met.

Show package version

To check the version of the package, run fpm publish --show-package-version.

Show upload data

You can see all the data being sent to the registry before uploading by running fpm publish --show-upload-data. The token will be included if you specify it on the command line (fpm publish --show-upload-data --token <token>). No network request will be performed. A tarball will be created, which you can inspect before publishing.

Dry run

A dry run can be performed with fpm publish --token <token> --dry-run. This will create the tarball and simulate the upload without publishing the package to the registry. The package and the token will be verified by the registry, and you will be provided with the path to the locally created tarball for inspection. By including the --verbose flag, you will be able to see all the data being sent to the registry.

Publishing

To publish a package, run fpm publish --token <token> using the token you generated on the website. You can as well include the --verbose flag to see all the data being sent to the registry.