All jobs

Add Build Provenance Attestations to a Rust CLI's Release Workflow

Yes. An agent adds signed build provenance for every binary archive and Debian package a Rust CLI's release workflow uploads, verifies one with gh, and opens a PR.

Run this on RushOpens the console with this prompt ready to send, in a Project that has your repository.

What the agent does

The agent reads the release job before it adds a step, because provenance has to cover exactly the files users download and nothing else. In a tool like sharkdp/hyperfine, Cargo.toml names the crate hyperfine at version 2.0.0, rust-version = "1.97.0", a [profile.release] with lto = true, strip = true and codegen-units = 1, a build.rs that generates shell completions with clap_complete, and a doc/hyperfine.1 man page. The one workflow, .github/workflows/CICD.yml, runs on pull_request, pushes to master and every tag. Its crate_metadata job reads name, version, maintainer, homepage, MSRV and binary name out of cargo metadata into outputs; build is a thirteen-target matrix across Ubuntu, macOS and Windows runners, with cross for the ARM and musl targets, that builds with --locked --release, runs the tests, and in a Create tarball step packs the binary, README, licences, changelog, man page and completions into a .tar.gz or .zip named hyperfine-v<version>-<target>; on Ubuntu a Create Debian package step builds a .deb with fakeroot dpkg-deb. Both files go to actions/upload-artifact@master, and when GITHUB_REF matches refs/tags/v[0-9], softprops/action-gh-release@v3 publishes them with GITHUB_TOKEN. A winget job then runs vedantmgoyal2009/winget-releaser@v2. No job declares permissions, so each runs with the repository's default token permissions.

The change is one step per matrix leg, placed after both package steps and before the release upload, and a permissions block the job did not have. The agent adds permissions: { contents: write, id-token: write, attestations: write } to the build job, since contents: write is what action-gh-release already needed implicitly and the other two are what signing needs, and leaves the other jobs at contents: read so the new block tightens rather than loosens. The step is actions/attest-build-provenance pinned to a commit with the version in a comment, with subject-path listing ${{ steps.package.outputs.PKG_PATH }} and ${{ steps.debian-package.outputs.DPKG_PATH }}; the second output is empty on macOS and Windows legs, so the agent writes the list through a small run step that emits only the paths that exist, because an empty entry in subject-path is a failure, not a skip. The step is guarded by the same steps.is-release.outputs.IS_RELEASE condition as the release upload, so pull request builds, which also run this job, sign nothing and need no id-token.

Two things in the workflow would make the attestation weaker than it looks, and the pull request fixes both. actions/upload-artifact@master is a floating ref, so the step that moves the files between jobs is unpinned while the step that signs them is pinned; the agent pins it to a commit with the version in a comment, the way the new step is. And cross builds the ARM and musl legs inside a container the workflow downloads at run time, which the provenance records as part of the build but does not pin; the agent pins taiki-e/install-action to a version rather than v2 and says in the description that the cross image digest is the remaining unpinned input. The README gets a short section under the install instructions: gh attestation verify hyperfine-v2.0.0-x86_64-unknown-linux-gnu.tar.gz --repo <owner>/hyperfine, with a sentence on what the command checks, that the archive's digest was signed by this repository's workflow on GitHub's runners.

Then it proves the shape of the result without cutting a release. In its own sandbox the agent runs actionlint on the edited workflow, builds the x86_64-unknown-linux-gnu leg's archive locally by replaying the Create tarball step's shell with cargo build --locked --release, and computes sha256sum for it, so the pull request can show the digest form the attestation will carry. It cannot sign from the sandbox, since Sigstore signing needs the workflow's OIDC token, so it instead runs gh attestation verify against a published release of a project that already attests, to show the verifier's output format, and quotes it as an example labelled as such. The pull request says plainly that the first signed artefacts appear on the next v* tag.

Start it with one API call

POST https://api.phoenix.so/o/{org}/sessions with this body:

{
  "agent": "claude",
  "input": "Add build provenance attestations to this Rust CLI's release workflow. Read Cargo.toml, build.rs and every step of .github/workflows/CICD.yml first, and list the artefacts each matrix leg produces and uploads. Add a permissions block to the build job with contents write, id-token write and attestations write, and give the other jobs contents read. After the tarball and Debian package steps and before the release upload, add actions/attest-build-provenance pinned to a commit with its version in a comment, with subject-path covering the archive and the Debian package only on legs that produce one, under the same release condition as the upload. Pin actions/upload-artifact and the cross installer to versions instead of floating refs and say what stays unpinned. Add a README section with the gh attestation verify command for one archive name. Run actionlint on the workflow, build the Linux archive the way the workflow does and print its sha256, run gh attestation verify against a release of a project that already attests to show the output format, label it as an example, and open a pull request that says the first attestations arrive with the next tag.",
  "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

A pull request that changes .github/workflows/CICD.yml and README.md. The description lists each matrix leg with the files it will attest, shows the permissions block before and after, quotes the actionlint run, the locally built archive's digest, and a labelled example of gh attestation verify output from another project, and names the cross container image as the one build input the provenance records but does not pin.

The CICD workflow runs on the pull request because it triggers on pull_request, so a reviewer sees the thirteen legs build and test with the new step skipped, which is the first check that the condition is right. The attestations themselves exist only after the next v* tag, and the description says so; a reviewer who wants proof before that can push a prerelease tag, which the workflow already marks prerelease from the version string.

Run it on every release tag

After the merge the workflow signs every release on its own, one attestation per archive and package, and a user verifies a download with the command in the README. An automation in the Project with the repository, with a github trigger on workflow_run.failure and the prompt "if the failed run is CICD on a tag and the attest step failed, read the job log and say in a comment whether the cause is a missing permission, an empty subject path or a Sigstore outage", answers the question a maintainer otherwise asks at release time.

For a second CLI, send this body again with its 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 already started. The run reads that workflow, so a project that publishes with cargo-dist or uploads a SHA256SUMS file gets subject-checksums pointed at that file instead of a path list.

The use case this job follows, with its automation and trigger: Hand off a long task.

Why run it on Rush?

Provenance is a two-line change that is easy to get wrong in a way nobody notices until a user runs the verify command: a subject-path that misses the Debian package, a step that runs on pull requests and fails for want of an OIDC token, or an attestation that signs a file built by an unpinned action. The agent reads every step of the real workflow, writes the list of artefacts per leg before touching YAML, and lints and rebuilds in its own sandbox, so the pull request arrives with the digest and the verifier's output format rather than a hope that the next tag works.

Every command stays with the run, and the pull request quotes them. The same change across every CLI a team ships costs no more attention than one, because each run reads that workflow's own package and upload steps and opens its own pull request.

Frequently asked questions

Why does the attest step not run on pull requests?

It is guarded by the same release condition as the upload step, so pull request and branch builds skip it. Signing needs the job's OIDC token through id-token: write, and a step that ran on every pull request would fail on forks and attest archives nobody downloads.

Does this change what gets released?

No. The archives, the Debian packages and the winget publication are produced by the same steps as before. The attestation is a separate signed statement stored by GitHub that names each file's digest, and gh attestation verify checks a download against it.

Can the agent produce a signed attestation in the pull request?

No. Sigstore signing uses the workflow's identity token, which only exists inside a GitHub Actions run. The pull request shows the digest of a locally built archive and a labelled example of the verifier's output from another project, and the first real attestations appear on the next tag.

What stays unpinned after this change?

The cross container images the ARM and musl legs build inside, which cross pulls by tag at run time. The provenance records that the build used them, and the description names this as the follow-up, along with the winget-releaser action's major tag.

More Rust CLI jobs

More jobs like this: Hand off a long task

Keep reading