# Versions and deployments

> How a Minekube game goes from your machine to players - revisions named by their content, assigned to label selectors in a Connect network, rolled back in one command, and swapped in while players stay connected.

On your machine, `mk dev` installs your game on the dev server. For players, the same bundles go to the servers of a [Connect network](https://minekube.com/guide/networks/), wherever those servers run. Each server swaps the new code in while players stay connected, as the dev server does.

> **Preview:**
> Publishing works on staging today, with `mk publish`, `mk revisions` and `mk unpublish`. The configuration in `vite.config.ts`, controlled updates, hostnames and platform updates are planned; their pages say so.

## Revisions and assignments

The model follows [Cloudflare Workers versions and deployments](https://developers.cloudflare.com/workers/configuration/versions-and-deployments/), with label selectors instead of shares of traffic:

| Cloudflare Workers | Minekube Games |
| --- | --- |
| A **version** is a fixed state of code and settings. | A **revision** is the bundles of one build. Its id is the hash of its bundles, so the same bundles are the same revision. |
| A **deployment** says which versions get traffic, at most two with a share each. | An **assignment** points a [label selector](https://minekube.com/guide/networks/labels#selectors) at a revision. A network can have any number of them side by side. |
| A version key keeps a user on one version. | A server runs exactly one revision per bundle, so all players on a server see the same game. |
| `wrangler rollback` | `mk publish --revision <id>` assigns an earlier revision again. |

A server runs the bundles of every assignment whose selector matches its labels. Where two assignments have a bundle of the same name, the newer one wins. Each server takes the bundles for its own platform: a Paper server the game, a Velocity proxy the network bundle.

## Who decides what

| Where | What |
| --- | --- |
| The project | The bundles, and the selector they go to |
| The server, in [`connector.json`](https://minekube.com/guide/networks/connector-json) | Its labels, such as `channel=canary`, its key and the network it joins |
| The network, with `mk network` and `mk trust` | Its owner, invites and trust rules |

The server says what it is. The project says which servers it targets.

## Steps

- **Create a network** and log in: [Create a network](https://minekube.com/guide/networks/create-a-network), in Connect.
- **Let servers in** with an invite, a trust rule, or your dev server: [Let servers in](https://minekube.com/guide/networks/let-servers-in), in Connect.
- **Publish a revision** to the servers a selector picks: [Publish a revision](https://minekube.com/games/versions-and-deployments/publish).
- **Roll back and unpublish**: [Roll back and unpublish](https://minekube.com/games/versions-and-deployments/rollback).
- **How a server gets its bundles**: [How servers get their bundles](https://minekube.com/games/versions-and-deployments/bundle-delivery).
- **What comes next**: the planned pages below.

- [Publish a revision](https://minekube.com/games/versions-and-deployments/publish) (Preview)
- [Roll back and unpublish](https://minekube.com/games/versions-and-deployments/rollback) (Preview)
- [How servers get their bundles](https://minekube.com/games/versions-and-deployments/bundle-delivery)
- [Vite plugin and configuration](https://minekube.com/games/versions-and-deployments/vite-plugin) (Planned)
- [Controlled updates](https://minekube.com/games/versions-and-deployments/controlled-updates) (Planned)
- [Hostnames and custom domains](https://minekube.com/games/versions-and-deployments/hostnames) (Planned)
- [Platform updates](https://minekube.com/games/versions-and-deployments/platform-updates) (Planned)
