本页尚未翻译,以下为英文原文。
#Publishing Packages
How to put your own library or program on the package registry, packages.nabi-lang.org, and keep it there. Using packages is covered in chapter 11, and features in chapter 18.
Important
For now only the registry's maintainers can publish. Anyone can sign in and use packages, but nabi login refuses an account that cannot publish yet.
#How the registry works
The registry's data is a single git repository, the index. Each version of a package is one line in it, naming a commit of the package's own git repository and that commit's tree hash. You upload no source: when a version is published, the registry fetches that commit, keeps an archive of it and writes the archive's SHA-256 into the line. Users download the archive and check it against the index, so a version outlives its repository. Lines are written only by the registry: the index takes no pull requests. The line format is described in the index README.
Packages published from the nabi-lang organization are marked Official; they come with the toolchain (chapter 11).
#The pages
| Page | What it covers |
|---|---|
| Publishing a package | what a package needs, nabi login, nabi publish, names and owners, the docs the registry makes, nabi yank |
| Trusted publishing | publishing from GitHub Actions with no stored token |
| Keeping an API stable | #[deprecated], #[non_exhaustive] and #[sealed] |
| Security advisories | nabi audit, reading an advisory, reporting a vulnerability |
The registry's own rules are on the registry: the usage policy, the terms of use and the privacy notice.
- 1Publishing a Package
Publishing adds one line to the registry index, pointing at a commit of your git repository (how the registry works). This page goes from the manifest to a published version, and how to withdraw one.
- 2Trusted Publishing
A GitHub Actions workflow can publish a package without any token stored in the repository. GitHub gives each job an OIDC token that says which repository, workflow and environment it runs for; the registry checks GitHub's signature on it and, when the package trusts that workflow, trades it for a publish token that lasts 30 minutes and works for that package only. It is the same scheme as crates.io's, PyPI's and npm's trusted publishing.
- 3Keeping an API Stable
Users of a published package build against it with a version requirement such as
^0.3, so a release in that range must not break their code. This page shows how to retire an API and how to leave room to grow. - Security Advisories
A security advisory says that some versions of a package have a vulnerability, which versions, and which version fixes it. The registry publishes them at packages.nabi-lang.org/advisories, in the OSV format other ecosystems use, and
nabi auditchecks your project against them.
Found a mistake? Edit this page on GitHub. Last updated