# Publish a chart

> Share a chart from your own git repository: pin it to one commit and its digest with alta publish, then list it in a charts repository with a pull request.

You share a chart from your own git repository. `alta publish` checks that the commit is pushed and prints two things: the `source` block that pins your chart to that commit and its digest, and the pointer a charts repository needs to list it. You add the pointer to a charts repository with a pull request; its review decides when people can install it.

**Before you begin (10 minutes)**

- A chart that passes `alta lint`: here `morning-brief`, from [your first chart](https://docs.os.altasystem.ai/charts/quickstart).
- A git repository with a remote in `https://`, readable without a password.
- For a chart others install: `"privacy": "shareable"` ([Share an agent](https://docs.os.altasystem.ai/charts/guides/share)) and a `locality` ([Say what your chart needs online](https://docs.os.altasystem.ai/charts/guides/declare-services)).

### Commit and push

`alta publish` only reads your repository: it never commits, pushes or fetches. Commit the chart's folder and push it first, so the commit it pins is one anyone can clone.

```sh [Terminal]
git add morning-brief
git commit -m "Morning brief"
git push
```

### Get the source and the pointer

`alta publish` checks the folder with the rules of `alta lint`, checks that it is committed and pushed, and computes the digest of the folder at that commit. It sends nothing: publishing is a dry run in this version.

```sh [Terminal]
alta publish morning-brief
```

```text [Output]
ready to publish (dry run: nothing sent)
  repository: ~/my-charts (folder morning-brief)
  remote: https://git.example.org/you/my-charts.git
  commit: 367162a590cd8cfe9441453303c8a067a8806788 (pushed)
  source:
    {
      "git": "https://git.example.org/you/my-charts.git",
      "commit": "367162a590cd8cfe9441453303c8a067a8806788",
      "sha256": "41ed48cb79cf57bb77603bdfea8319aa34ff8a41096fe668d60a608e327d91bc"
    }
  pointer for a charts repository (sources/morning-brief.json):
    {
      "git": "https://git.example.org/you/my-charts.git",
      "commit": "367162a590cd8cfe9441453303c8a067a8806788",
      "path": "morning-brief",
      "sha256": "41ed48cb79cf57bb77603bdfea8319aa34ff8a41096fe668d60a608e327d91bc"
    }
  1. Nothing was sent: publishing is a dry run in this version.
  2. Put this source in your chart.json (origin "community"); the content is in the folder morning-brief of the repository, commit and push.
  3. When the store imports it, it clones this commit, recomputes the tree digest and refuses any difference.
  4. To list it in a charts repository, open a pull request there that adds sources/morning-brief.json with the pointer above; its review builds the index entry (see https://docs.os.altasystem.ai/reference/advanced/specs/alta-index-0.1).
```

### Put the source in the chart

Copy the `source` block into `chart.json`, next to `"origin": "community"`. It says where the chart comes from: `git` is an `https://` address with no user name or password, `commit` the full 40-character commit (never a branch, nor a tag alone), `sha256` the digest. Never write `verified`: a community chart that says it is verified is refused.

```json [morning-brief/chart.json: source]
{
  "git": "https://git.example.org/you/my-charts.git",
  "commit": "367162a590cd8cfe9441453303c8a067a8806788",
  "sha256": "41ed48cb79cf57bb77603bdfea8319aa34ff8a41096fe668d60a608e327d91bc"
}
```

The placeholder warning is gone. Commit and push this change too.

```sh [Terminal]
alta lint morning-brief
```

```text [Output]
ok   morning-brief (chart)
1 checked, 0 errors, 0 warnings
```

### Open a pull request to a charts repository

A charts repository lists a chart kept in your repository with a pointer: one file, `sources/<chart id>.json`, holding the commit and the digest `alta publish` printed. Add it in a pull request. The first time, also add `publishers/<your id>.json` with your name and your handle on the host.

```json [sources/morning-brief.json]
{
  "git": "https://git.example.org/you/my-charts.git",
  "commit": "367162a590cd8cfe9441453303c8a067a8806788",
  "path": "morning-brief",
  "sha256": "41ed48cb79cf57bb77603bdfea8319aa34ff8a41096fe668d60a608e327d91bc"
}
```

The repository's checks clone your commit, recompute the digest and refuse any difference. Then a review sets the chart's status: until it does, the chart is listed but nobody can pull it. See [How charts are reviewed](https://docs.os.altasystem.ai/marketplace/review).

## A new version

Change the chart, raise its `version`, write what changed in `changes`, commit, push, and run `alta publish` again: a new commit is a new digest, so it is a new pointer and a new review. A new version that asks for more (a new service, a new sign-in, more permissions) asks the owner again before it installs.

## Pitfalls

| Do | Avoid |
|---|---|
| The full commit, 40 characters | A branch or a tag: they move |
| An `https://` address anyone can clone | An address with a user name, a password or a token: refused |
| The same rules as any chart: closed list, a proof for each part, `support`, `locality` | Expecting a community chart to do more: it never runs code, and never ships scripts |
| Saying in the summary what your chart does | Calling it verified: refused |

**Next:**

- [How charts are reviewed](https://docs.os.altasystem.ai/marketplace/review)
- [Validate in CI](https://docs.os.altasystem.ai/guides/tools/validate-ci)
- [alta publish](https://docs.os.altasystem.ai/reference/cli/publish)
