# `mix nbpr.publish`
[🔗](https://github.com/jimsynz/nbpr/blob/v0.7.0/lib/mix/tasks/nbpr.publish.ex#L1)

Uploads a tarball produced by `mix nbpr.pack` to the first supported backend
declared in the package's `artifact_sites:`. When `config :nbpr, :registry`
is set, that project registry is used first.

    mix nbpr.publish <Module> <path-to-tarball>

e.g.

    mix nbpr.publish NBPR.Jq /path/to/nbpr_jq-1.7.1-...-cb13a42462c2806d.tar.gz

## Backends

  * `{:oci, "<host>/<owner>[/<path>]"}` — pushes to an OCI registry such as
    Forgejo. Project credentials use `NBPR_REGISTRY_USERNAME` and
    `NBPR_REGISTRY_TOKEN`; see `NBPR.Artifact.Registry`.

  * `{:ghcr, "ghcr.io/<owner>"}` — pushes a pure-Elixir OCI artefact to
    `ghcr.io/<owner>/<package>:<tag>`. Requires `GHCR_TOKEN` or
    `GITHUB_TOKEN` in the environment (with `write:packages` scope).
  * `{:github_releases, "<owner>/<repo>"}` — uploads via `gh release` to
    tag `<package>-v<package-version>`, creating the release if needed.
    Requires `gh` on PATH and authenticated.

Sites are tried in `artifact_sites` order; the first site whose backend has
the required CLI installed is used.

## Flags

  * `--draft` — only applies to `github_releases`; creates the release as a draft on first creation.
  * `--prerelease` — only applies to `github_releases`; marks the release as a prerelease on first creation.
  * `--force` — applies to OCI/GHCR registries; re-pushes even when the tag is already published. By default, `nbpr.publish` checks the registry for the tag and skips re-pushing — NBPR's cache-key model treats published tarballs as immutable, so re-pushing the same tag is wasted work in CI.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
