Skip to content

ci serve: run releases on the host, with the same steps the rendered release workflow runs #5462

Closed

Description

@lex00

chant ci serve should run releases on its host, as it runs pull-request jobs and build requests. A release on the chant-native git forge (--forge git), or on any forge where a team runs chant's jobs on its own host, should then get the same publish, signing, scan and checks the rendered release workflow gives.

Epic: #5452. Related: #4016 (the git forge), #4168 (the release workflow), #4169 (build requests in ci serve).

What exists, checked at chant 3bf0df0

  • chant release workflow renders the publish job for github, forgejo and gitlab only (RELEASE_WORKFLOW_FORGES in workspace/release-workflow.ts). It has two shapes:

    • a publish job that runs when a release/** tag (or a release.tag tag) appears;
    • a dispatch shape that runs the whole release when started by hand: doctor, stamp, images, cut and publish.
  • On top of that:

    • the security groups add --require-provenance and chant release verify;
    • signing installs cosign pinned by SHA-256 and sets CHANT_COSIGN.
  • chant ci serve (workspace/ci-serve.ts):

    • runs plan, record and apply for pull requests and the target branch;
    • runs ci tick from its own signed runs;
    • with --build-command, serves ci/build/* tags in a fresh worktree;
    • takes a git-ref lease per apply group.

    Nothing in it reads release/** tags or runs chant release.

  • So on --forge git there is no generated way to release. A person runs chant release cut and chant release publish by hand on some machine. Every step the rendered workflow adds has to be remembered by hand:

What it should be

  • The publish. ci serve serves releases, opt-in with --release. Each poll fetches the release tags. For each tag it has not served, it runs the same steps the rendered publish job runs, in the same order and from the same step list (release-steps), so the two cannot drift:
    • in a fresh detached worktree of the tag, the install, the build of what the targets upload, and the fetch of the ci tags and chant/lifecycle;
    • then chant release publish --yes, with the flags the security groups add.
  • The tool installs. The installs the rendered workflow does are done on the host, from TOOL_PINS, checksum-checked and cached in the state directory: cosign, and the scanner and syft from release publish: scan every artifact before the stage, with a pinned scanner, under supply-chain #5446. A host with no network for them names the missing tool and stops before the stage.
  • Dispatch. A dispatch request is an annotated ci/release/<sha> tag, pushed the way chant ci run --at pushes ci/build/<sha>. ci serve runs the dispatch shape for it (doctor, stamp, images, cut, publish) when the commit is green under ci.green, and deletes the tag after.
  • One publisher. A lease on refs/chant/lease/release makes two hosts serving one repository publish once.
  • Credentials. Registry credentials come from --secrets, as job secrets do today. They are passed only to the publish, never to the build.
  • Signing.
  • The record. Each served release appends to _releases/publishes.jsonl as a rendered publish does. It names the host's runner key, so who-ran-it covers it.
  • State. The served release tags live in the ci serve state file beside its jobs, and a failed publish is retried as a failed job is.

Done when

  • On a bare git remote (--forge git), pushing a release tag makes ci serve --release publish to a local registry fake. The record names the runner key, and nothing publishes twice with two hosts serving.
  • A ci/release/<sha> request on a green commit cuts and publishes. On a commit that is not green it is refused with the reason.
  • With supply-chain on, the host publish runs the same steps as the rendered GitHub job. A test compares the two step lists.
  • A train release (chant workspace train publish) is served the same way, and its step list is compared with the rendered train workflow's.
  • The ci serve reference (cli/ci.mdx) and the land-without-a-pull-request guide describe releasing from the host. The forge matrix (docs: forges, CI systems and wardens, with a feature matrix and why only forges get a warden #5461) gets its release column for ci serve.

Pull requests, in order

  • 1. ci serve --release serves release tags: the publish steps from release-steps, the host tool installs, the record and the state, for a single release and a train.
  • 2. Dispatch requests (ci/release/<sha>) on green commits, and the refs/chant/lease/release lease.

Activity

  1. added
    epic:ci-hardening
    on Nov 21, 2026
  2. lex00 commented on Nov 22, 2026

    @lex00
    ContributorAuthor

    Design for both pull requests, settled against the code on the epic's integration branch.

    PR 1: ci serve --release serves release tags

    How the steps stay the same. chant release workflow now reads its input through one function, releaseWorkflowInputAt, which ci serve calls too. The host renders the release workflow from that input with the tag trigger, parses the publish job out of the rendered file, and runs its steps in order. So the host does not keep a second list of steps that a test has to hold in line with the first: it runs the job the renderer writes. A test still compares the host's steps with the rendered GitHub job's, step for step.

    The host renders the Forgejo flavour. Its steps are the GitHub job's without what only GitHub's hosted runners have: the job token for a forge: "github" target and the npm upgrade for trusted publishing. The test shows the difference is exactly the tool installs and that npm line.

    Running a step. Each run: step goes through bash -eo pipefail in the job's working directory, with RUNNER_TEMP, GITHUB_ENV, GITHUB_OUTPUT, GITHUB_PATH, GITHUB_REF_NAME and GITHUB_SHA set and read back after the step. The step gets the runner's base variables and --pass-env, never GITHUB_ACTIONS or another forge's run variables, so the publish sees a host. The checkout is a fresh detached worktree of the tag's commit, and the toolchain set-up actions are the host's own toolchains. Any other action, and release.workflow.builds (which needs runners of its own), fails the release with the reason.

    Tools. cosign, grype and syft are installed from TOOL_PINS into <state>/tools, each checked against its SHA-256. The host puts CHANT_COSIGN, CHANT_GRYPE and CHANT_SYFT in the job's env, which is what makes the rendered job leave out its own install steps. A host that already sets one of those variables uses its own tool. ci serve --release installs the tools before its first poll, so a host that can't download one, or runs on a platform chant has no pin for (the pins are linux/amd64 and linux/arm64), stops there and names the tool.

    Credentials. ${{ secrets.NAME }} in the job reads the --secrets file, in the step or job that names it, as a forge reads repository secrets. The step that runs release publish or workspace train publish also gets the file's secrets for a new jobs.release allowlist entry (every secret when the file has no such entry). No other step gets them.

    Signing and the builder. ci serve --release refuses to start when any release signs keylessly, and, under supply-chain, when a release that publishes does not sign with kms or key. It also needs a trusted runner key. Every step gets CHANT_RELEASE_RUNNER_KEY_FINGERPRINT, so releaseBuildKind sees a host and the SLSA statement names ci-serve/<fingerprint> as the builder. The run id ci serve gives the job reaches the publish through CHANT_CI_RUN_ID. Each line in _releases/publishes.jsonl gets a new optional runnerKey field with the fingerprint.

    State. The state file keeps each tag under release:<tag>, with its status, attempts, failure and the path of its log. On the first pass with --release the release tags already there are noted as baseline and not run, the same way the target branch's first head is a baseline. A failed release runs again with --rerun-failed, and the publish resumes from its record.

    Which tags: release/** for the legacy template, the tags a release.tag template makes (not its floating tag), and release-train/<env>/<id> at a train's root. The release config is read at the tag's commit. A config that can't be read there before its install, because it imports a package, is read from the serve's clone instead, with a warning.

    PR 2: dispatch requests and the release lease

    A dispatch request is an annotated tag ci/release/<sha> whose message carries a small JSON record: the commit, the label (default auto), the levels for a train (default auto), and when it was asked. chant ci run --at <sha> --release [--label <label>] [--levels <levels>] pushes it, the same way ci run --at pushes ci/build/<sha>.

    For each request, ci serve --release renders the dispatch shape of the release workflow with gate: "head". It runs that file's gate and cut jobs on the host, with inputs.label (or inputs.levels) from the request and GITHUB_SHA set to the requested commit. The gate refuses a commit that is not green, and the refusal's own line becomes the request's recorded reason. The cut runs the doctor, the stamp, the images and the cut, and pushes the release tag (or the train tag). The publish is then the tag path from PR 1 on the next poll. So a dispatched release on a host runs the same doctor, cut and publish steps the workflow does, with the publish rebuilding from the tag as a tag-triggered publish job does. The request tag is deleted on the remote once it has been served or refused, and the state file keeps it under dispatch:<sha>.

    The lease. Serving a release tag and serving a request each take the git-ref lease release, which is refs/chant/lease/release at the workspace root. They take it with requirePush, renew it while the job runs, and release it after. A host that finds the lease held waits for a later poll. Once a host holds the lease it checks two things on the remote. For a tag, it looks for the marker refs/chant/released/<tag>, which a host pushes after a successful publish. For a request, it checks the request tag still exists. If the marker is there or the request is gone, it records the item as served elsewhere and runs nothing. So two hosts serving one repository publish each release once.

    What the code says that the issue did not

    • The epic's acceptance criteria ask for "a refusal for an unpinned FROM". release images: digest-pinned bases, a re-pin command and pull login for any Dockerfile, under supply-chain #5457 made that a report in workspace check and a warning in release doctor. Nothing in the cut or the publish refused, on a forge or anywhere else. The refusal now lives where every path builds release images, chant release cut and chant release images: under supply-chain they read the Dockerfile entries with the same unpinnedFroms and stop with release-image-base-unpinned before anything is built. That covers the rendered workflows on all three forges, the train and the host. The doctor's check stays a warning.
    • --require-provenance off GitHub Actions and GitLab CI is already met by the key- or KMS-signed SLSA statement after release.signing: KMS, key and private Sigstore modes, and signing on Forgejo #5458, so the host needs no change in release-publish.ts beyond the record field.
    • --release already takes a value elsewhere (components promote --release <label>). Under ci, a bare --release is the flag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    epic:ci-hardening

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions