Releasing a new version of ks

We use the goreleaser project to automate building and marking releases for ks.
This does the following for us:

  1. Builds binaries across platforms and creates release tarballs/zips.
  2. [optionally] Creates a changelog based on all PRs since the last release.
  3. Creates a github release, uploading the changelog and the release archives.
  4. Updates homebrew formula to point to the new release.

This is super convenient! But it is a little more involved than just running a command as we lock down our homebrew tap repo.

Detailed instructions follow.

Install and configure goreleaser

Follow the instructions on https://goreleaser.com for downloading and installing goreleaser.

In addition to getting the utility itself installed you need to make sure that you have a github token created and set in an environment variable.
Do this by going here and ensure that the repo scope is selected.
Take the resultant token and set it in a GITHUB_TOKEN environment variable.
Multiple utilities (including ks itself!) will use this token so this isn’t a bad thing to have set up all the time.
Make sure you don’t check this token in anywhere thought!

  1. export GITHUB_TOKEN=<long hex number>

Tag a release

We use semantic versioning to tag a release.
See semvar.

  1. VERSION=v0.9.0
  2. git tag -a $VERSION -m $VERSION
  3. git push origin $VERSION

If you have GPG signing set up for git, you can add an -s above to create a signed tag.

Create and clone fork of ksonnet/homebrew-tap

You are going to have to create a PR for the updated homebrew tap file.
As such, go to https://github.com/ksonnet/homebrew-tap and hit the “fork” button.

Then do the following someplace:

  1. git clone git@github.com:GITHUB_USER_NAME/homebrew-tap.git ksonnet-homebrew-tap
  2. cd ksonnet-homebrew-tap
  3. git remote add upstream git@github.com:ksonnet/homebrew-tap.git
  4. git fetch upstream

Update your fork of ksonnet/homebrew-tap

If your fork isn’t caught up with the upstream repo you need to do this as goreleaser will write directly to github and you want to minimize merge conflicts later.

  1. cd ksonnet-homebrew-tap
  2. git fetch upstream
  3. git pull
  4. git rebase upstream/master
  5. git push

Copy and update .goreleaser.yml

Back in the ksonnet directory

  1. cp .goreleaser.yml $TMPDIR

Now edit $TMPDIR/.goreleaser.yml and update the brew section to point to your repo.

Build and push release

  1. goreleaser --config $TMPDIR/.goreleaser.yml

[optional] Custom release notes

If you want custom release notes (instead of the autogenerated ones) then create a markdown file ($TEMPDIR/release-notes.md) and run this instead.

  1. goreleaser --config $TMPDIR/.goreleaser.yml --release-notes $TMPDIR/release-notes.md

At this point, if everything goes well, there should be a new release at https://github.com/ksonnet/ksonnet/releases. Check it out and make sure it looks good.

Create PR for brew update

  1. cd ksonnet-homebrew-tap
  2. git pull
  3. git commit --amend --reset-author --signoff --no-edit
  4. git push origin -f

Now go to your fork on github and create a PR for the updated brew formula.
This will be on your master branch so you’ll have to hit the “New pull request” button explicitly.