# Add a Release Workflow With Prebuilt Binaries to a Tokio Server

Yes. An agent adds a tag-driven GitHub Actions workflow that builds your Tokio binaries for Linux, macOS and Windows, attaches them to a release, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-release-workflow/tokio/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent starts from how the crate is already built and tested, because a release workflow that disagrees with CI ships binaries nobody has run. In a server laid out like tokio-rs/mini-redis, `Cargo.toml` declares one package, `mini-redis` at version 0.4.1 on edition 2018, with two binaries: `mini-redis-server` from `src/bin/server.rs` and `mini-redis-cli` from `src/bin/cli.rs`. Both parse arguments with `clap` 4 using the derive feature, the server binds a `TcpListener` and hands it to `server::run` with `signal::ctrl_c()` as the shutdown signal, and an optional `otel` feature pulls in `opentelemetry`, `tracing-opentelemetry`, `opentelemetry-aws` and `opentelemetry-otlp`. `Cargo.lock` is committed and there is no `rust-toolchain` file, so the stable toolchain is what builds it. The only workflow, `.github/workflows/ci.yml`, runs on pushes and pull requests to `master` across `ubuntu-latest`, `macos-latest` and `windows-latest`: `cargo build --verbose`, the same build with `--features otel`, `cargo test --verbose` with and without that feature, and `cargo fmt --all --check`. Nothing runs on a tag, and no release has binaries attached.

The agent writes `.github/workflows/release.yml` with `on: push: tags: ['v*']` and `permissions: contents: write`, the one permission `softprops/action-gh-release` needs to create the release and upload assets. A first job checks the tag against the crate: it reads the `version` field with `cargo metadata --no-deps --format-version 1` and fails early when `v0.4.1` on the tag does not match `0.4.1` in `Cargo.toml`, so a mistyped tag never produces a release named for the wrong version. The build job then fans out over a matrix of targets with the runner for each: `x86_64-unknown-linux-gnu` on Ubuntu, `x86_64-apple-darwin` and `aarch64-apple-darwin` on macOS, and `x86_64-pc-windows-msvc` on Windows. Each leg installs the toolchain with `dtolnay/rust-toolchain@stable` and the matrix `targets` value, then runs `cargo build --release --locked --bins --target <triple>`. `--locked` is deliberate: the lockfile is committed, so a release built from a resolved set that differs from what CI tested is refused rather than silently accepted.

Packaging follows what the OS expects. On Linux and macOS a step copies `mini-redis-server` and `mini-redis-cli` from `target/<triple>/release/` beside `LICENSE` and `README.md` into a directory named `mini-redis-<version>-<triple>` and makes a `.tar.gz` of it; on Windows the same files with `.exe` suffixes go into a `.zip` made with PowerShell's `Compress-Archive`. Every leg writes a `.sha256` file next to its archive with `shasum -a 256` or `certutil`, and uploads both as workflow artifacts. A final `release` job downloads every artifact, runs `action-gh-release` with `files` set to the archives and checksum files, `generate_release_notes: true`, and `draft: false`, so one job owns the release and partial uploads from a failed matrix leg never appear on it. The `otel` feature is left out of the shipped binaries, because `ci.yml` treats it as an optional build and the README presents it as an example, and the pull request says so.

Before opening the pull request the agent runs the Linux leg's steps in its own sandbox: `cargo build --release --locked --bins` for the host target, the packaging script, and a check that the archive contains both binaries and that `./mini-redis-server --version` prints the version `clap` embeds from `Cargo.toml`. It does not push a tag or create a release, and it does not change `ci.yml`, `Cargo.toml` or the `.gitignore`, which already ignores `/target`.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add a GitHub Actions release workflow to this Tokio crate. Read Cargo.toml, Cargo.lock, .github/workflows/ci.yml, README.md and src/bin/ first. Write .github/workflows/release.yml that runs on tags matching v*, checks that the tag matches the version in Cargo.toml using cargo metadata, builds every binary in the crate with cargo build --release --locked --bins for x86_64-unknown-linux-gnu, x86_64-apple-darwin, aarch64-apple-darwin and x86_64-pc-windows-msvc using dtolnay/rust-toolchain, packages each target as a tar.gz or zip named after the crate, version and target with LICENSE and README.md inside, writes a sha256 file for each archive, and uploads them to a GitHub release with softprops/action-gh-release in one final job with contents: write permission. Leave optional cargo features out of the shipped binaries. Build the Linux target and run the packaging steps in the sandbox, check both binaries are in the archive and print their --version, and open a pull request that explains how to cut a release. Do not create a tag or a release, and do not change ci.yml.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

The pull request adds one file, `.github/workflows/release.yml`, and nothing else. Its description lists the four targets and the runner each builds on, shows the archive names the workflow produces for the current version, pastes the sandbox output of the Linux release build and the `--version` line from each packaged binary, and spells out the release procedure: bump `version` in `Cargo.toml`, merge, then push a tag such as `v0.4.2`.

The workflow does not run on the pull request itself, because its trigger is a tag. The existing `CI` workflow runs as before and is the check a reviewer sees. The first real exercise of the release job is the next tag, and the description says which log lines to look at on that run: the version check, the `--locked` build on each leg, and the asset list on the release.

Before merging, a reviewer decides whether the target list is right for the people who install the binaries, whether Linux users also need a `musl` build that runs on distributions with older glibc, and whether releases should be created as drafts so someone can read the generated notes before they go public.

## Run it on every Rust crate that ships a binary

An organisation with several Tokio services can send this body once per repository from its own server, each a `POST /o/{org}/sessions` with that repository in `resources` and a `request_id` that is a UUID v5 of the repository's full name, so a retried call returns the run it already started. Each run reads its own `Cargo.toml`: a workspace with several binary crates gets one archive per crate, a crate with a `rust-toolchain.toml` builds on that channel instead of stable, and a crate whose CI already runs `cargo deny` or `cargo audit` keeps that step ahead of the release job.

To keep the workflow current after it merges, an automation on the Project with a `github` trigger on `workflow_run.failure` and the prompt "if the failed workflow is release, read the failed leg's log, name the target and the step that failed, and comment on the commit with the smallest fix" turns a red release into a specific comment. Automation runs are read-only, so the comment is all it posts, and only work by an owner, member or collaborator fires it.

## Why run it on Rush?

A release workflow is mostly conditionals that are hard to get right from memory: which runner builds which target, where `cargo` puts a cross-compiled binary, how the archive differs on Windows, and which permission the release action needs. The agent reads the crate's binaries and its CI matrix first and writes the workflow to match them, then runs the Linux leg end to end in its own sandbox rather than pushing a guess and waiting for a tag to fail.

The build log, the archive listing and the `--version` output stay with the run and are pasted into the pull request, so the review is of a release procedure that has been exercised at least once. Several crates get the same treatment at once, each with its own binary names and targets.

## Frequently asked questions

### Why check the tag against Cargo.toml?

Because `clap` embeds the version from `Cargo.toml` into `--version`, and a tag that says `v0.5.0` on a crate still at 0.4.1 would ship binaries that report the wrong version. The first job compares the two with `cargo metadata` and stops before any build runs.

### Why `--locked`?

`Cargo.lock` is committed, and `ci.yml` tests against it. `--locked` makes the release build fail instead of resolving a different set of dependency versions, so what is attached to the release is what CI tested.

### Does it cross-compile for Linux ARM?

Not by default. The four targets build natively on GitHub's Ubuntu, macOS and Windows runners. The pull request names `aarch64-unknown-linux-gnu` as the next target to add and says it needs either an ARM runner or a cross-compilation step, which is a choice for the team.

### Will the workflow run on my pull request?

No. Its only trigger is a tag that starts with `v`. The Linux steps were run in the sandbox and their output is in the description; the first full run is the next tag you push, and `CI` keeps running on pull requests as it does now.

### Can it publish to crates.io too?

It could, but this change does not. A `cargo publish` step needs a crates.io token as a repository secret and a decision about who may cut a release, so the description lists it as a follow-up rather than adding a step that would fail without the secret.

## More Tokio jobs

- [Add Connection Timeouts to a Tokio Server](https://getrush.ai/run/add-request-timeouts/tokio/)
- [Add Structured JSON Logging to a Tokio Server](https://getrush.ai/run/add-structured-logging/tokio/)
- [Add TLS to a Tokio TCP Server](https://getrush.ai/run/add-tls/tokio/)

## The same job on other stacks

- [Add a Release Workflow for a VS Code Extension](https://getrush.ai/run/add-release-workflow/vscode-extension/)
- [Add a Release Workflow for a Chrome Extension](https://getrush.ai/run/add-release-workflow/chrome-extension/)
- [Add a GitHub Release Workflow With CPack Packages to a CMake Project](https://getrush.ai/run/add-release-workflow/cmake/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
