It is boring to write release scripts, and I was like in need to write one more.
So, I changed what I already had in antibody and make it simple enough so it can be used within any go project, basically.
What it does?
- Compiles the project with
goxto several platforms, setting the
main.versionldflag to current git tag name;
- Packages it in
tar.gzfiles in the form of
binary_$(uname -s)_$(uname -m).tar.gz, so it could be easily scripted;
- Creates a github release for the current tag, setting the description of it with the commit log between the current and previous tags;
- Finally, upload all
tar.gzfiles to the created release.
This is kind of opinionated, so, your project will need to "follow some rules" in order to use it.
- Go 1.5 or higher;
- No Windows support - I just don't care;
main.versionldflag - it's useful to the users;
- It has a
LICENSE*files - because of the users, again;
distfolder should not contain anything important.
Basically, all is done in a very simple
getopts loop, so, you need to run it
curl -s https://raw.githubusercontent.com/caarlos0/go-releaser/master/release | bash -s -- \ -u caarlos0 \ # repo owner on github -r go-releaser \ # repo name on github -b release \ # binary filename -m ./cmd/main.go \ # your main go file -e "FILE1 FILE2 FILE3" # optional, extra files you want to add, besides the binary itself with LICENSE* and README*
For example, in antibody's
circle.yml file I have the following:
deployment: release: tag: /v[0-9]+(\.[0-9]+)*/ commands: - curl -s https://raw.githubusercontent.com/caarlos0/go-releaser/master/release | bash -s -- -u getantibody -r antibody -b antibody -m ./cmd/antibody/ -e antibody.zsh