sourcegraph/src-cli

Automate versioned Homebrew formula publishing

Closed this issue · 0 comments

Follow up to #852.

Currently our release process for src-cli only publishes to the main (unversioned) Homebrew formula, which overwrites whatever the last latest version was so that it can be automatically installed with brew install sourcegraph/src-cli/src-cli. Ideally, it is possible to install the latest with the main formula, or install any prior version with a specific version command, e.g. brew install sourcegraph/src-cli/src-cli@4.0.2.

From this blog post, we understand that publishing a versioned formula and publishing the main formula require different goreleaser configs, because the naming scheme needs to change. We are also constrained in that we cannot easily re-run a release for a given version multiple times without deleting the artifacts uploaded to GitHub and updating all of SHA256 references to them.

To get around these constraints, I think we could implement the following in our GitHub actions workflow:

  1. Fetch the previous latest release version tag.
  2. Copy the current main release formula file (src-cli.rb) to a versioned formula file matching that tag (e.g. src-cli@4.0.2.rb), and update the class name to match. Commit the result.
  3. Run goreleaser like normal; this updates the main formula again.
  4. Remove the existing symlink for the last version and create a new one for the new version.

The next time we release a new version of src-cli, this should automatically get us:

  • a versioned formula for the previous release (that you could install with brew install sourcegraph/src-cli/src-cli@4.0.2)
  • a new versioned formula for 4.0.3 (that you could install with brew install sourcegraph/src-cli/src-cli@4.0.3)
  • an updated main formula (e.g. what you get when you brew install sourcegraph/src-cli/src-cli) that points to 4.0.3 instead of 4.0.2