Switch to dark theme

Releases

A release moves one project in one environment to a commit. urepo compares the desired commit with the commit live there and applies the change when both gates pass. GitHub holds all state: requests are runs of the release workflow, and what is live is a GitHub deployment. There is no deployment server to run, and the release workflow needs only its own github.token.

The runnable example in examples/release has three environments and a release that prepares its checkout. Every urepo release command reads GitHub and needs GITHUB_TOKEN or GH_TOKEN.

Environments

Environments in .urepo/urepo.toml form one chain. Exactly one environment names the branch that feeds it in source, and every later environment names the one before it in after:

TOML
# .urepo/urepo.toml
[workspace]
name       = "harbor"
urepo      = "202612.4.0"

[environment.dev]
source = "main"
auto   = true

[environment.qa]
after = "dev"

[environment.prod]
after = "qa"

What is desired

An environment with auto = true releases the newest commit of the main branch that changes the project or a project it depends on and passes its checks. It never looks further back than the live commit, so a failing commit never rolls it back.

Every other environment releases the newest request. A request is a run of the release workflow that workflow_dispatch started on the main branch with the inputs project, environment and commit. The workflow's run-name writes those inputs into the run's name, such as release hub@prod 7c1e0d4a9b1f, and urepo reads the name back through the Actions runs API. The newest such run that succeeded or is still running is the request. A run that failed does not count, and neither does a run on another branch or a run whose name asks for something else. The account that started the run is the one who asked.

Anyone who can dispatch a workflow can request a release. That permission is the authorization.

Request a release with urepo release request:

Shell
urepo release request hub@prod                    # the commit live in qa
urepo release request hub@prod --commit 7c1e0d4a  # any commit of main

Without --commit, the request names the commit live in the preceding environment. urepo checks that the commit is on the main branch, names it in full, and dispatches the release workflow with it. You can also dispatch the workflow from the Actions tab with the same inputs. A request for a commit that is not on the main branch desires nothing.

A rollback is an ordinary request for an earlier commit.

What is live

After a successful apply, urepo writes a GitHub deployment on the environment's own name, such as prod, with the task urepo:<project>, the commit as its ref, and the status success. The live commit is the commit of the newest deployment of that environment and task whose newest status is success. A failed release writes nothing, so the commit live before stays live. urepo release list hub@prod prints these deployments, newest first.

The two gates

Gate Passes when
checks Every cached task of the project and the projects it depends on has a trusted store record at the target commit, and every {image:NAME} in apply has a trusted digest
after The target commit is live for the project in the preceding environment

A request can waive after with a reason. checks cannot be waived.

Shell
urepo release request hub@prod --commit 7c1e0d4a --override after --reason "qa is down"

The waiver travels in the run's name: release hub@prod 7c1e0d4a override after because qa is down.

A project that takes no part in the preceding environment is held by after until its release table says what it follows. after = "<environment>" names an earlier environment it does release to. after = false follows none, so the gate is absent. Only a release table sets after = false.

Release tables

A project joins an environment by declaring [release.<environment>]:

TOML
# gateway/urepo.toml
[release.prod]
apply   = "sh tools/release/gateway {environment} {commit} {from}"
plan    = "sh tools/release/gateway --plan {environment} {commit} {from}"
prepare = ["bundle"]
runner  = "ubuntu-24.04"

apply and plan run with sh -c in the workspace root, with these placeholders replaced:

Placeholder Value
{project}, {environment} The release's project and environment
{commit} The target commit
{from} The commit live before the release, empty when none is
{image:NAME} The image's digest from the trusted records at the target commit

Set use = "pulumi" to delegate plan and apply to the built-in pulumi extension instead.

plan and apply deploy the target commit's files. When the workspace is checked out at the target commit they run in it. Otherwise urepo checks the target commit out beside it, in .urepo/local/trees/, runs them there, and removes the tree afterwards, so a clone needs the whole history (fetch-depth: 0).

prepare lists tasks that run in that checkout before plan and apply, so the commands find what the tasks make. The checkout is loaded as its own workspace, so the tasks are the target commit's, and the tasks they wait for run first. A failing task of prepare fails the release before apply runs, and fails a plan.

Release commands and extensions see the caller's whole environment, with the tools the lock pins for the project first on PATH, as urepo tool run gives them. A locked tool the machine lacks is installed first; one that cannot be installed stops the release before it applies anything.

runner is the runner label of the job that applies the release, ubuntu-latest by default.

Pulumi

use = "pulumi" releases the Pulumi project in the project's folder, whose stack for each environment has the environment's name. Every pulumi command runs without prompts and with the caller's environment, which names the backend (PULUMI_BACKEND_URL, such as an S3 bucket for a self-managed state) and holds the passphrase or key for secrets. Pin pulumi in [tools] so every release uses the same version, or put it on the PATH.

  • plan runs pulumi install, pulumi stack select <environment> --create, and pulumi preview --refresh, with one step for each resource the preview changes, so a change made outside Pulumi shows as a step too.
  • apply runs the same two commands and pulumi up --refresh.

The release workflow

release.yml runs after the check workflow succeeds on the main branch, and on each dispatch. Its pending job runs urepo ci apply --list, which lists every release whose desired commit is not live and whose gates pass now. It writes each held release, with the gate that holds it, to the job's summary. The apply job runs urepo ci apply <project>@<environment> for each listed release, in the concurrency group urepo-<environment>-<project>. Each run computes the desired commit, the live commit and the gates again, so a release that a gate holds by then is reported as held and the job still succeeds.

Each apply job runs on the release table's runner inside the GitHub environment named after the urepo environment, with deployment: false, so a release to prod reads the secrets of the GitHub environment prod. Put deployment credentials there, and limit each of those GitHub environments to the main branch, so a dispatch of an edited workflow on another branch never reaches them.

urepo release status prints, for each project and environment, the live commit, the desired commit, who asked for it, and the gate that holds it. urepo release plan prints what a release would do, runs prepare and the plan command, and exits 3 when a gate holds it.