# Publish a package

Source: https://docs.lightair.app/developers/extend/publish

> Build, check and publish a Lightair package with lightair-pack, register its GitHub Release with the catalog, and set up its listing page.

In short:
- `lightair-pack build my-pack` packs a folder into `.airpkg` files and checks them. `lightair-pack check` runs the catalog's static checks alone.
- `lightair-pack publish` puts the files on an immutable GitHub Release in a public repository. Lightair stores no package files.
- Register the release at packages.lightair.app/publish. The catalog checks it and lists it; helpers also wait for an admin.
- The package's page reads its text and pictures from a `listing/` folder in the repository.

Publishing has three parts: build the package with `lightair-pack`, put it on a GitHub Release
you own, and register that release with a catalog, which checks it, signs it and lists it.
Lightair's catalog is at `packages.lightair.app`. To list packages in a catalog of your own, see
[Run a community catalog](/developers/extend/run-a-catalog).

## Install lightair-pack

`lightair-pack` is in [lightair-core](https://github.com/Lightair-Project/lightair-core). Install
it with Cargo:

```sh
cargo install --locked --git https://github.com/Lightair-Project/lightair-core lightair-pack
```

## Build

```sh
lightair-pack build my-pack --out dist
```

`build` reads the package folder (its `lightair-package.json` and files, see
[Packages](/developers/extend/packages)) and writes `.airpkg` files into `--out`, the current
folder when left out. The output folder must be outside the package folder.

- **Pictures are cleaned:** every image is re-encoded, which drops hidden metadata. The build
  prints each file it changed.
- **One file per platform** when a [helper](/developers/extend/helpers) has programs for several:
  `<name>-<version>-<platform>.airpkg`, each with the shared files and that platform's program.
  Otherwise one `<name>-<version>.airpkg`.
- **Checked afterwards:** each file goes through the static checks. The command fails if one
  doesn't pass.

To make a package from a show instead, use **Export as package…** in Lightair, then build the
folder it writes.

## Check

```sh
lightair-pack check dist/my-pack-1.0.0.airpkg
lightair-pack check my-pack --json report.json
```

`check` takes a `.airpkg` or a folder and runs the same static checks the catalog runs. It prints
each note and failure with the file it's about, then `Checks: passed.` or `Checks: failed.`, and
exits with an error when something failed. `--json` also writes the full report.

| Check | What fails it |
|---|---|
| `archive` | The archive or the manifest can't be read safely: bad paths, too large, a manifest that isn't valid |
| `files` | A file whose name and contents don't agree, a kind of file Lightair doesn't know, a file a content kind can't hold (programs outside helpers, WebAssembly, archives inside the package), files outside every content folder other than a README, licence, icon and previews, images that don't decode, damaged fonts or models, invalid JSON |
| `permissions` | Widget, script or template code that reaches a host the manifest doesn't declare (`network:<host>`); script code built at runtime (`eval`, `new Function`); a helper program that uses powers a sandboxed helper can't have |
| `secrets` | Something that looks like a private key or an API token (GitHub, AWS, Anthropic, OpenAI, Google, Slack, Stripe, Twitch or Discord) |
| `licence` | No licence, or one that isn't a valid SPDX expression (`MIT`, `CC-BY-4.0`, `MIT OR Apache-2.0`); code without a `LICENSE`, `LICENCE` or `COPYING` file at the top |
| `widgets` | A widget's `manifest.json` that can't be read, or a `skin` that names no built-in widget |

Notes don't fail a package: code that builds addresses at runtime, or an unsigned macOS helper,
for example.

## Publish the release

Your package lives on your own GitHub Release, in a public repository. Turn on release
immutability in the repository first (**Settings › General › Releases**): catalogs refuse releases
whose files can change.

```sh
lightair-pack publish dist/my-pack-1.0.0.airpkg --repo you/my-pack --no-register
```

`publish` takes `.airpkg` files or package folders (it builds folders first) and:

1. Runs the static checks on each file, and stops if one fails.
2. Makes sure the repository is public.
3. Makes a release tagged `v<version>` (or `--tag`), named "<name> <version>", with `--notes` as
   its text.
4. Uploads each `.airpkg` and a copy of the manifest as `lightair-package.json`, then publishes the
   release.
5. Warns when the release isn't immutable.

Every file of one version must have the same id, version, permissions and Lightair range.

| Option | What it does |
|---|---|
| `--repo owner/name` | The GitHub repository. Required. |
| `--tag <tag>` | The release's tag. `v<version>` by default. |
| `--notes <text>` | The release's text. |
| `--no-register` | Stops after the release. |
| `--api <url>` | The catalog to register with, when not stopping. `https://packages.lightair.app` by default. |
| `--force` | Publishes even when the checks fail. |

It signs in to GitHub with `GITHUB_TOKEN` or `GH_TOKEN`, or with the GitHub command line's sign-in
(`gh auth login`).

No command line? Make the release on GitHub's page, attach the `.airpkg` files and the package's
`lightair-package.json`, and register it.

An asset named `<anything>-<platform>.airpkg` is that platform's file (`macos-arm64`, `macos-x64`,
`windows-x64`, `windows-arm64`, `ios`, `android`); any other `.airpkg` is for every platform. A
release holds at most one file per platform.

## Register it

Sign in at `packages.lightair.app` with GitHub and register the release on **Publish** with its
repository and tag. The catalog refuses a release when:

- your GitHub account doesn't have two-factor authentication on;
- the repository isn't yours or an organisation's you administer, or isn't public;
- the release isn't published or isn't immutable;
- it has no `lightair-package.json`, or that isn't valid JSON with an id, name, version and contents;
- the tag isn't the manifest's version (`1.2.0` or `v1.2.0`);
- it has no `.airpkg`, or two for one platform;
- the version was registered before, or isn't higher than the latest: a changed package needs a
  new version number;
- a package that isn't a helper asks for `full-access`, `full-access` is asked for later, or a
  package without a script or helper has `optional_permissions`.

**Who may publish which id.** Your packages' ids start with `io.github.<your login>` or
`io.github.<organisation>` for an organisation you administer. To publish under your own domain,
add it in your account and prove it: a TXT record `lightair-publisher=<code>` at
`_lightair.<domain>`, or the code in a file at `https://<domain>/.well-known/lightair-publisher`.
Its ids then start with the domain reversed (`com.example.`), and your packages show as from a
verified publisher. Ids under `app.lightair.` are Lightair's own, and a name that claims to be
Lightair or official is refused.

## The catalog's checks

Once registered, the version goes through the checks of
[lightair-checks](https://github.com/Lightair-Project/lightair-checks), public GitHub Actions
workflows:

- **Linux, always:** the static checks, a headless run (templates and transitions drawn, shaders
  compiled, media probed, recipes tried, widgets opened in a headless browser, scripts run against
  a stand-in Lightair), and malware scans.
- **macOS and Windows, for helpers:** the helper started in Lightair's own sandbox. A connection
  or file it reaches outside its permissions fails it.

Then the catalog compares what the runners downloaded with the release: the same files, and in
each the same id, version, permissions, optional permissions and Lightair range as the release's
`lightair-package.json`. Code is read by an automated reviewer, and code that addresses a reviewer
or an AI fails. Previews from the run are checked against the content policy.

A version that passes is signed and listed, most often within minutes. Helpers, and anything with
full access, wait for an admin's review first. Follow a version's checks on its page at
`packages.lightair.app`.

## The listing

What the package's page shows lives in its repository, in a `listing/` folder, so changing it needs
no new version:

```
listing/listing.json
listing/icon.png
listing/screenshot-1.png … listing/screenshot-6.png
```

```json
{
  "tagline": "Neon alerts and a chat box",
  "description": "Two widgets and a stinger, in pink and cyan.",
  "links": { "source": "https://github.com/you/my-pack", "support": "https://example.com/help" }
}
```

| File | Rules |
|---|---|
| `listing.json` | `tagline` up to 140 characters, `description` up to 4,000 (longer text is cut). `links`: each name 1 to 20 lower-case letters, each address `https://`. |
| `icon.png` | Square; PNG, JPEG or WebP. |
| `screenshot-1` to `screenshot-6` | PNG, JPEG or WebP. The first is the card's picture. |

Every file is optional, and each picture is at most 1 MB. The listing is read when a version is
published, at that version's commit, and when you refresh it from the package's page, where
**Preview** shows the page first and **Make it live** stores it. Text and pictures are moderated.

## Related

- [Packages](/developers/extend/packages)
- [Run a community catalog](/developers/extend/run-a-catalog)
- [Install packages](/desktop/chat-and-widgets/packages)
