# Releases

Each deployment uploads a complete release: manifest, backend and all static files. A release never changes afterwards.

## What happens

| Status         | What the platform does                                                           |
| -------------- | -------------------------------------------------------------------------------- |
| `validating`   | checks the manifest, paths, sizes, hashes and contents, then the code            |
| `uploading`    | stores the files                                                                 |
| `provisioning` | creates the database at the first release that asks for one, uploads the backend |
| `verifying`    | starts the backend and calls `/__boringcloud/health`                             |
| `ready`        | done. The URL switches to this release at once                                   |
| `failed`       | stopped. The previous release keeps serving                                      |

The call answers at the end, so there is nothing to poll. People who have a page open get the new version when they reload it.

With two deployments at the same time, the first to finish is published. The other answers `ready_not_published` over MCP, or `"published": false` over REST and in the CLI. If it is the right one, make it live with a rollback to it.

## The check of the code

Every release is checked, whatever the way it is sent.

- **A password or key refuses the release.** The answer is `VALIDATION_FAILED`, with the rule, file and line in `details.issues`, never the value. Remove it, and tell the person to replace it at the provider. Do not split, encode or hide a value to pass the check.
- **Risky code gives a warning** in `deployment.findings`: HTML or SQL built from text, `eval`. The release goes live. Fix what is in your code and deploy again. Tell the person about warnings that come from a library.

```json
{ "rule": "risk.sql", "severity": "warning", "file": "worker.mjs", "line": 12, "message": "…" }
```

The check compares text with known patterns. It does not see a missing permission check, for example, so no finding does not mean that the code is safe. See [Secure code](https://boring-cloud.app/docs/secure-code.md).

## Retry

After a network error you may not know whether a release was created. Send the same idempotency key again, with the same content: you get the first result instead of a second release. The CLI does this by itself when it retries. Over MCP, pass `idempotencyKey`.

Do not retry a `VALIDATION_FAILED`. Fix the files first.

## Go back

- MCP: `list_deployments`, then `rollback_app` with the `id` of a release whose status is `ready`.
- CLI: `boringcloud deployments list --app <id>`, then `boringcloud rollback --app <id> --to <deployment-id>`.

**Only code and static files go back. Data and files stay as they are.** This is why tables may only grow, see [Database](https://boring-cloud.app/docs/database.md).

## Keep room

An app keeps 25 releases and accepts 60 deployments per day. When it is full, remove old releases with `POST /api/v1/apps/<id>/deployments/prune` and `{"keep": 5}`. The current one is never removed.

## Check before you deploy

1. `index.html` exists and loads its script from a file.
2. The backend starts without a user, for the health check.
3. Every route checks who is asking. See [Secure code](https://boring-cloud.app/docs/secure-code.md).
4. Changes to tables only add.
5. No key, token or password in any file.
6. With the CLI, `boringcloud pack --dir .` passes.
