|
| 1 | +# Deployment scripts |
| 2 | + |
| 3 | +`deploy.sh` builds and publishes the komet-node release artifacts. It is the |
| 4 | +single source of truth for the deployment steps: the `Release` workflow |
| 5 | +(`.github/workflows/release.yml`) invokes its subcommands, and you run the same |
| 6 | +subcommands by hand when CI is unavailable. |
| 7 | + |
| 8 | +## What it does |
| 9 | + |
| 10 | +The script has three subcommands: |
| 11 | + |
| 12 | +| Subcommand | Action | |
| 13 | +| ----------- | ------ | |
| 14 | +| `nix-cache` | Builds `.#komet-node`, pushes the full build closure to the `k-framework` Cachix cache, publishes the kup-installable binary to the `k-framework-binary` cache, then verifies the push and pin. Both caches are public; `binary` is a historical name, not an access level. | |
| 15 | +| `docker` | Builds the runtime image from `Dockerfile`, runs `komet-node --help` in it as a smoke test, then pushes it to Docker Hub. | |
| 16 | +| `all` | Runs `nix-cache` then `docker`. | |
| 17 | + |
| 18 | +The image tag is `runtimeverificationinc/komet-node:ubuntu-jammy-<version>`, |
| 19 | +where `<version>` comes from `package/version`. |
| 20 | + |
| 21 | +## Prerequisites |
| 22 | + |
| 23 | +Both subcommands run from a checkout of the revision you are releasing, with the |
| 24 | +following tools on `PATH`: |
| 25 | + |
| 26 | +- `nix-cache` needs `nix` and `cachix`. It fetches `kup` from |
| 27 | + `github:runtimeverification/kup` itself, so you do not install kup separately. |
| 28 | +- `docker` needs `docker`. |
| 29 | + |
| 30 | +Each subcommand checks its tools up front and exits with a clear message if one |
| 31 | +is missing, before starting the build. |
| 32 | + |
| 33 | +The project devcontainer (`.devcontainer/`) provides all of these: `nix` and |
| 34 | +`cachix` are installed into the Nix profile, and the docker-in-docker feature |
| 35 | +supplies `docker`. If you added these to an existing container, rebuild it |
| 36 | +("Dev Containers: Rebuild Container") so the new tools are present. |
| 37 | + |
| 38 | +Provide the secrets as environment variables. Everything else has a default (see |
| 39 | +the `Shared configuration` block in `deploy.sh`), so a normal checkout needs no |
| 40 | +further setup. |
| 41 | + |
| 42 | +| Subcommand | Required environment variables | |
| 43 | +| ----------- | ------------------------------ | |
| 44 | +| `nix-cache` | `CACHIX_PUBLIC_TOKEN`, `CACHIX_PRIVATE_KFB_TOKEN` | |
| 45 | +| `docker` | `DOCKERHUB_PASSWORD` | |
| 46 | + |
| 47 | +`OWNER_REPO` and `REV` default to the current checkout's `origin` remote and |
| 48 | +`HEAD`. Override them if you are publishing a revision other than the one checked |
| 49 | +out. `DOCKERHUB_USERNAME`, `DOCKERHUB_NAMESPACE`, and `DOCKERHUB_REPO` default to |
| 50 | +the release account and repository; override them only to publish elsewhere. |
| 51 | + |
| 52 | +Both subcommands refuse to run if the working tree is not clean. CI builds from a |
| 53 | +fresh checkout, so a manual build must too: uncommitted changes and untracked |
| 54 | +files would otherwise be baked into the published image or flake build without |
| 55 | +matching the `REV` they are published under. Commit, stash, or clean the tree |
| 56 | +first. `git status --porcelain` ignores `.gitignore`d paths, so runtime artifacts |
| 57 | +and dev caches do not count. Set `ALLOW_DIRTY=1` to override the check when you |
| 58 | +deliberately want to publish an uncommitted state. |
| 59 | + |
| 60 | +## Manual release while CI is down |
| 61 | + |
| 62 | +The workflow also drafts, cleans up, and finalizes the GitHub release around the |
| 63 | +deployment jobs. When you deploy by hand, run those `gh` steps yourself in this |
| 64 | +order. `nix-cache` runs once per architecture (the workflow uses an `x86_64` and |
| 65 | +an `ARM64` runner), so run it on a machine of each architecture that should be |
| 66 | +cached. |
| 67 | + |
| 68 | +```sh |
| 69 | +VERSION=v$(cat package/version) |
| 70 | + |
| 71 | +# 1. Draft the release. |
| 72 | +gh release create "$VERSION" --draft --title "$VERSION" --target "$(git rev-parse HEAD)" |
| 73 | + |
| 74 | +# 2. Deploy. Export the secrets first (see the table above). |
| 75 | +# Run nix-cache once per architecture; docker once. |
| 76 | +./scripts/deploy.sh nix-cache |
| 77 | +./scripts/deploy.sh docker |
| 78 | + |
| 79 | +# 3. Finalize the release once every deployment has succeeded. |
| 80 | +gh release edit "$VERSION" --draft=false |
| 81 | + |
| 82 | +# If a deployment fails, remove the draft instead: |
| 83 | +# gh release delete "$VERSION" --yes --cleanup-tag |
| 84 | +``` |
0 commit comments