# Add a GitHub Release Workflow to a Go CLI

Yes. An agent reads your Makefile and tags, writes a tag-triggered workflow that cross-compiles each binary and attaches it to a GitHub Release, and opens a PR.

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

## What the agent does

The agent reads how releases are made today before writing a workflow. In a tool like rakyll/hey, `go.mod` declares `module github.com/rakyll/hey` with `go 1.24.0` and one direct dependency, `golang.org/x/net` v0.48.0. The `Makefile` has a `release` target that cross-compiles with `GOOS` and `GOARCH` for windows, linux and darwin on amd64 into `./bin/hey_<os>_<arch>`, an `upload` target that copies `./bin/*` to a `gs://hey-releases/` bucket with `gsutil`, and `release-upload` chaining both; the README's install section links to those three files on `storage.googleapis.com`. Six tags exist, `v0.1.0` through `v0.1.5`, but no GitHub Release carries binaries. `.github/workflows/go.yml` runs `go build -v ./...` and `go test -v ./...` on push and pull request to `master` with `actions/setup-go@v4` pinned to `go-version: '1.21'`, three minors behind what `go.mod` asks for, so every CI run leans on the toolchain auto-download. A `.travis.yml` asking for Go 1.13 and a `Dockerfile` starting from `golang:1.15` are leftovers the agent notes but does not touch. Tests live in `hey_test.go` (header and auth flag parsing) and `requester/requester_test.go` (`TestN`, `TestQps`, `TestRequest`, `TestBody`), and `hey.go` hard-codes the user agent as `hey/0.0.1`.

The workflow it writes, `.github/workflows/release.yml`, runs on `push` of tags matching `v*` with `permissions: contents: write`, the one scope attaching assets needs. A `build` job uses a matrix of the Makefile's three targets plus `linux/arm64` and `darwin/arm64`, which the Makefile does not build and the pull request calls out as an addition, and each cell runs `actions/setup-go` with `go-version-file: go.mod` so the workflow and the module can never disagree again. The build line is `CGO_ENABLED=0 go build -trimpath -ldflags '-s -w -X main.version=${{ github.ref_name }}'`, and to give that flag somewhere to land the agent adds a `version` variable to `hey.go` defaulting to `dev`, a `-version` flag that prints it, and uses it in the user agent in place of the fixed `0.0.1`. Output names keep the Makefile's shape, `hey_linux_amd64` and so on, with `.exe` on Windows, so the README's install links only change host. A `release` job that `needs: build` downloads every artifact, writes `checksums.txt` with `sha256sum`, and runs `gh release create` with the tag's name and all files, using `GITHUB_TOKEN`.

The agent makes the tests a gate: the release job also needs a `test` job that runs `go test ./...` and `go vet ./...`, and it updates `go.yml` to `go-version-file: go.mod` so the two workflows agree. In its sandbox it runs the tests, then cross-compiles every matrix cell locally with the same `GOOS`, `GOARCH` and flags to prove each target links, and runs `actionlint` over both workflow files. What it cannot do is push a tag: the sandbox never creates tags or releases on the reader's repository, so the pull request says the first tag push after merge is the real end-to-end check and spells out the two commands that trigger it.

Documentation changes ride along: the README install section points at the Releases page and shows `sha256sum -c checksums.txt`, and the Makefile's `release` target stays for anyone building locally while a comment notes that `upload` to the bucket is no longer how binaries ship.

## 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 Go CLI. Read go.mod, the Makefile, the existing workflows, the README install section and git tags first. Write a workflow that runs on tags matching v*, with contents: write only, that cross-compiles the same targets the Makefile builds plus linux/arm64 and darwin/arm64 with CGO disabled, -trimpath and a version injected through ldflags, names binaries the way the Makefile does, writes a sha256 checksums file and creates a GitHub Release with every file attached. Add a version variable and a -version flag to the main package and use it in the user agent. Make the release job depend on the tests passing, use go-version-file in both workflows so they match go.mod, run the tests, cross-compile every matrix target locally to prove it links, lint the workflows with actionlint, update the README install links, and open a pull request that says the first tag push is the end-to-end check. Do not create tags or releases.",
  "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

What comes back is a pull request that adds `.github/workflows/release.yml`, edits `.github/workflows/go.yml` to read the Go version from `go.mod`, adds the `version` variable and `-version` flag to `hey.go`, and updates the README's install section. The description lists each matrix target, says which two the Makefile never built, names the one permission the workflow asks for and why, and shows the `-version` output from a local build.

The run's record holds the `go test ./...` and `go vet` output, one `go build` per target with its flags, and the `actionlint` result, so a reviewer can see every binary links before the workflow ever runs.

Before merging, a reviewer reads `release.yml` for the trigger and permission, confirms `go.yml` passes on the pull request itself, and after merging pushes the next tag and watches the Release appear with five binaries and `checksums.txt`. Downloading one and running `sha256sum -c` closes the loop the sandbox could not.

## Run it on every new CLI repository

An organisation that keeps several Go tools can start this job for each one from a short script: list the repositories the GitHub App reaches with `GET /o/{org}/github`, skip any that already has a workflow under `.github/workflows` that runs on tags, and send this body once per remaining repository as the `resources` URL. Give each request a `request_id` that is a UUID v5 of the repository's full name, so running the script twice returns the runs it already started instead of opening a second pull request.

The key's `run.completed` webhook fires once per run with the session URL, which is enough to collect the pull request links in one place as they open.

## Why run it on Rush?

A release workflow is only trusted once it has produced a release, and nobody wants to push a tag to find out a matrix cell does not link. The agent cross-compiles every target in its own sandbox with the exact flags the workflow uses, runs the tests the release job will gate on, and keeps that output in the run's record, so the first tag push after merge is a confirmation rather than an experiment.

It also fixes what it finds on the way, such as a CI workflow pinned to an older Go than `go.mod` requires, and it works the same across every CLI in an organisation, so ten tools can get the same reviewed workflow in one afternoon from one script rather than ten copy-paste attempts.

## Frequently asked questions

### Why not use GoReleaser?

GoReleaser is a good fit for many projects, and the agent will use it if the prompt asks. This job keeps to plain `go build` and `gh release create` so the workflow does exactly what the Makefile already did, with nothing new to learn or configure, and the whole thing fits in one file a reviewer can read top to bottom.

### Will the agent push a tag to test the workflow?

No. The run never creates tags or releases on your repository. It proves each target builds by cross-compiling locally with the workflow's flags and lints the YAML; the pull request names the tag push after merge as the end-to-end check and shows the commands.

### Why does the workflow need contents: write?

Creating a GitHub Release and uploading assets to it are writes to the repository's contents, and that is the only scope the workflow asks for. The build and test jobs need nothing beyond reading the code, and the permission is set at the workflow level so a new job cannot silently get more.

### What about Windows binaries and the .exe suffix?

The Makefile wrote `hey_windows_amd64` with no extension, which runs but confuses Windows users. The workflow appends `.exe` for the windows target and the README says so; the Linux and macOS names are unchanged so existing instructions keep working.

## More Go CLI jobs

- [Add an SBOM to a Go CLI's GoReleaser Release](https://getrush.ai/run/add-sbom-to-release/go-cli/)
- [Add Shell Completion to a Go CLI from a Linear Issue](https://getrush.ai/run/add-shell-completion/go-cli/)
- [Add Snapshot Tests to a Go CLI's Rendered Output](https://getrush.ai/run/add-snapshot-tests/go-cli/)

## The same job on other stacks

- [Add a Release Workflow for a Jekyll Theme Gem](https://getrush.ai/run/add-release-workflow/jekyll/)
- [Add an npm Release Workflow to a Lit Component](https://getrush.ai/run/add-release-workflow/lit/)
- [Add a Release Workflow for a Maven Library](https://getrush.ai/run/add-release-workflow/maven/)

## 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/)
