docs

You are reading the docs for v0.1.2. Nabi 0.1.2 is no longer supported. Latest release: v0.1.3 →

#2. Trusted Publishing

On this page

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.

Set it up once per package:

  1. On your account page, under Trusted publishers, add the package, its GitHub repository (owner/repo), the workflow's file name (publish.yml) and, if the job runs in a GitHub environment, its name. Only the package's owners can add one, and while publishing is not open yet only the registry's maintainers. A package with no owner on record (one the registry's maintainers wrote into the index directly with nabi publish --index-dir) gets its first trusted publisher from them.
  2. Add the workflow below to the repository as .github/workflows/publish.yml. It runs when a v* tag is pushed, checks that the tag matches version in nabi.nabion, trades the job's OIDC token (audience packages.nabi-lang.org) for a publish token, logs in with it and publishes.

Then release with git tag v0.3.1 && git push origin v0.3.1. For a tag pushed before the workflow was in the repository, run it by hand from the Actions tab (or gh workflow run publish.yml -f tag=v0.3.1): it runs the workflow from the default branch and publishes the tag's commit. Instead of nabi login, the step can put the token in NABI_REGISTRY_TOKEN for the publish step (echo "NABI_REGISTRY_TOKEN=$tok" >> "$GITHUB_ENV").

Any ref of the named workflow file may publish. Give the publisher an environment: make a GitHub environment (release) with required reviewers and a deployment rule for v* tags, set environment: release on the job, and name it here; the registry then refuses tokens from runs outside it. Without one, protect your v* tags if others can push to the repository. The version page names the workflow that published it.

A version already in the index without its metadata (one the registry's maintainers wrote directly with nabi publish --index-dir) gets it from the same command: nabi publish of the same tree fills in the description, license, README and the rest, and changes nothing else.

#Further reading

Found a mistake? Edit this page on GitHub. Last updated