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.
- Compiles the project with
gox
to several platforms, setting themain.version
ldflag to current git tag name; - Packages it in
tar.gz
files in the form ofbinary_$(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.gz
files 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.version
ldflag - it's useful to the users;- It has a
README*
andLICENSE*
files - because of the users, again; - The
dist
folder should not contain anything important.
Basically, all is done in a very simple getopts
loop, so, you need to run it
like this:
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
You can see the very first release made this way here as well the build that created it.