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:
- Builds binaries across platforms and creates release tarballs/zips.
- [optionally] Creates a changelog based on all PRs since the last release.
- Creates a github release, uploading the changelog and the release archives.
- 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!
export GITHUB_TOKEN=<long hex number>
Tag a release
We use semantic versioning to tag a release.
See semvar.
VERSION=v0.9.0
git tag -a $VERSION -m $VERSION
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:
git clone git@github.com:GITHUB_USER_NAME/homebrew-tap.git ksonnet-homebrew-tap
cd ksonnet-homebrew-tap
git remote add upstream git@github.com:ksonnet/homebrew-tap.git
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.
cd ksonnet-homebrew-tap
git fetch upstream
git pull
git rebase upstream/master
git push
Copy and update .goreleaser.yml
Back in the ksonnet
directory
cp .goreleaser.yml $TMPDIR
Now edit $TMPDIR/.goreleaser.yml
and update the brew section to point to your repo.
Build and push release
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.
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
cd ksonnet-homebrew-tap
git pull
git commit --amend --reset-author --signoff --no-edit
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.