Build cross-platform binaries for Go
MIT License
gogo-release is a simple POSIX shell script to:
It's the simpler and unix-beardy brother of go-releaser.
Configure it by just editing the source or adding a .gogo-release
file; this
is simply a shell script that's sourced and can be used to set/override some
variables. Here is an example. See the gogo-release
script for a list of
things you can set with documentation.
Usage:
gogo-release
dist
.Notes:
The current commit must have a tag, so if you want to build v1.2.0:
$ git checkout v1.2.0
$ gogo-release
You can also add a version as a commandline argument; this will only put the version in the name, and won't check out the git commit:
$ gogo-release v1.2.0
This is mostly intended for testing.
Cross-compiling code that uses cgo is tricky as cross-compiling C code is tricky; I wrote a bit more about that over here: Statically compiling Go programs. In brief:
-linux-
should work).CGO_ENABLED=1
is set, e.g. by adding export CGO_ENABLED=1
to.gogo-release
.CC=..
to the build-ldflags='-extldflags=-static'
to createAn alternative might be xgo, which may be a bit easier to cross-compile cgo code depending on what you want and personal preferences.
Define a gogo_before_exit
function in your .gogo-release
to run something
after everything is done. Just add the lines to the script if you want to run
something before the building starts; for example:
start=$(date +%s)
gogo_before_exit() {
echo "Took $(( $(date +%s) - $start )) seconds"
ls -lh "$tmp" | awk '{print $5 " " $9}'
}
A previous version also included code for automatically creating a GitHub
release and uploading it. I later removed this as I felt it was a bit too
complex and automagic. Uploading is just a few clicks anyway, so it doesn't
really save that much effort (I got carried away). You can still add it in
gogo_before_exit
if you want.