All jobs

Add an SBOM to the Release of a Cobra CLI

Yes. An agent adds Syft SBOM generation to a Cobra CLI's GoReleaser config, proves it with a snapshot release, and opens a pull request.

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 how the binary is released before it adds anything. In a kubectl plugin like stern/stern, go.mod is go 1.27.2 with github.com/spf13/cobra v1.10.2, and .goreleaser.yaml is a version: 2 config with two builds, unix for linux and darwin on amd64, arm and arm64, and windows for amd64 and arm64, both with CGO_ENABLED=0 and -s -w plus three -X flags for cmd.version, cmd.commit and cmd.date. Archives come in two ids, tgz for every platform and zip for windows, each wrapping only the binary and LICENSE; checksum writes checksums.txt; dockers pushes four tags to ghcr.io/stern/stern from a Dockerfile that copies the binary onto gcr.io/distroless/static-debian13; krews writes a manifest with skip_upload: true; and winget opens a pull request against microsoft/winget-pkgs. There is no sboms section and no signs section.

The Makefile pins the tools: GORELEASER_VERSION ?= v2.18.3, installed with go install into hack/tools/bin, golangci-lint v2.15.0, validate-krew-manifest and yq. make dist pipes the config through yq to keep only linux amd64 and runs goreleaser release --skip=publish --snapshot; make dist-all does the same for every platform; make release runs goreleaser release --clean --skip=validate. .github/workflows/release.yaml runs on v* tags: checkout, setup-go from go.mod, a docker/login-action to ghcr.io, make release with GITHUB_TOKEN and the winget author variables, then rajatjindal/krew-release-bot with dist/krew/stern.yaml. ci.yaml runs make dist and make validate-krew-manifest on every pull request, so a config change is exercised there before any tag.

The agent adds an sboms block to .goreleaser.yaml with artifacts: archive, so every tar.gz and zip gets a document, and a second entry with artifacts: binary so a user who downloads only the binary has one too. It keeps GoReleaser's default command, syft, with its default spdx-json output and the default name {{ .ArtifactName }}.sbom.json, and sets ids on the archive entry to tgz and zip so the Docker image, which is built from the same binary, is not described twice. Because syft is a separate binary, it adds a SYFT_VERSION variable to the Makefile next to the others, a $(SYFT) target that installs it with go install github.com/anchore/syft/cmd/syft@$(SYFT_VERSION) into hack/tools/bin, makes dist, dist-all and release depend on it, and puts hack/tools/bin on PATH for those targets so GoReleaser finds it. The yq filter in make dist keeps working because it edits builds, not sboms.

Then it proves the change the way the repository already does: make dist for a one-platform snapshot, which must now produce dist/stern_<version>_linux_amd64.tar.gz.sbom.json beside the archive, and make dist-all to confirm every archive id gets one. It opens an SBOM to check it lists the module path and the Go version from go.mod, and runs syft by hand on the archive to compare. The release workflow needs no new step, since make release now installs Syft, but the agent adds a short note to CONTRIBUTING.md about the new tool and to the README's release section, and because krews and winget read the archive list, it re-runs make validate-krew-manifest to confirm the manifest still points at the archives and not at the SBOM files.

Start it with one API call

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

{
  "agent": "claude",
  "input": "Add SBOM generation to the release of this Cobra CLI. Read .goreleaser.yaml, the Makefile, go.mod, Dockerfile and every workflow under .github/workflows first, and list the builds, archive ids, checksum, docker, krew and winget sections and how the Makefile pins each release tool. Add an sboms section with one entry for archives and one for binaries, keeping GoReleaser's default Syft command and file naming, with ids so no artifact is described twice. Install Syft the way the Makefile installs its other tools, pinned by version into the same tools directory, and make the dist, dist-all and release targets depend on it with that directory on PATH. Run make dist and make dist-all and confirm an .sbom.json appears beside every archive, open one to check it names the module path and Go version, and re-run the krew manifest validation. Document the new tool where the repository documents releases. Open a pull request that lists each artifact and the SBOM file it gets.",
  "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 with the sboms block in .goreleaser.yaml, the SYFT_VERSION variable, $(SYFT) target and dependency edits in the Makefile, and the documentation lines. Its description lists each archive and binary with the SBOM file name it will get on the next tag, the make dist and make dist-all output showing those files in dist/, and the packages one SBOM lists for the module; the snapshot release's full log and the SBOM files themselves are in the run's record.

A reviewer checks that the ids on the archive entry match the archive ids already in the config, so the Docker image and the krew manifest are untouched, and that the Syft version pinned in the Makefile is one they want to maintain alongside the GoReleaser pin. The release workflow is unchanged, so the first real proof is the next tag, and the snapshot output in the description is what to compare it against.

Run it on every terminal hand-off

A maintainer asked for an SBOM by a downstream packager starts this from the terminal with this body and the CLI's repository in resources, and goes back to the issue queue. The run reads the real GoReleaser config and the real Makefile, so Syft is installed and pinned the way the repository already handles its tools rather than through a new action in the workflow.

Send a request_id, a UUID, with the body so a retried start returns the run it already began. When the turn ends, GET /o/{org}/sessions/{id} names the pull request, and a follow-up to the same session can ask for a signs section with cosign on the checksums and SBOMs in the same branch.

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

Why run it on Rush?

Release configuration is only right when a release runs, and nobody wants to find out on a tag. The agent runs the repository's own snapshot targets in its own sandbox, with GoReleaser and Syft installed at the pinned versions, and the pull request carries the dist/ listing and the contents of one SBOM, so a reviewer sees the files the next tag will attach rather than trusting a diff of YAML.

The same run fits any Go CLI released with GoReleaser, whether it pins tools in a Makefile, installs them in the workflow, or uses the GoReleaser GitHub Action: the agent follows the convention it finds. Each repository gets SBOMs for the artifacts it ships, and every run keeps the full record of the snapshot release it made to prove it.

Frequently asked questions

Which SBOM format does it produce?

GoReleaser's default, SPDX JSON from Syft, named <artifact>.sbom.json beside each archive. A follow-up can switch the args to cyclonedx-json or add a second document per artifact; the config keys are in the pull request for either.

Does the Docker image get an SBOM too?

Not from this change. The ids on the archive entry name only the archive ids, so the image built from the same binary is not described twice through the archive. Attaching an SBOM to the image is a separate step with Syft against the pushed image and a registry attachment, which the pull request notes as a follow-up.

Why install Syft through the Makefile instead of a workflow action?

Because the repository already pins GoReleaser, golangci-lint and the krew validator that way, and the release workflow calls make release. Installing Syft the same way means make dist on a laptop and the tagged release produce identical SBOMs, and there is one place to bump the version.

Will the SBOM files break the krew or winget manifests?

No. Both read the archive list, and the SBOMs are separate files alongside the archives. The agent re-runs the krew manifest validation after the snapshot release to confirm, and the output is in the pull request.

More Cobra jobs

The same job on other stacks

More jobs like this: Hand off a long task

Keep reading