gogo-release is a simple POSIX shell script to:
- Cross-compile binaries to various different targets.
- Optionally compress the binaries.
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:
- [Mad coding].
- Hide yo wife, hide yo kids, commit yo code.
- Create a new tag.
gogo-release
- Create new GitHub release, upload contents of
dist
. - Have a celebratory beer, release party, drug binge, orgy, Satanic sacrifice.
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:
- Make sure you have the required C compiler cross-build tools installed;
you can usually install these from your distro's package manger (names
vary; searching for
-linux-
should work). - Make sure
CGO_ENABLED=1
is set, e.g. by addingexport CGO_ENABLED=1
to.gogo-release
. - Make sure the right compiler is used by adding
CC=..
to the build matrix. - You probably want to add
-ldflags='-extldflags=-static'
to create statically linked binaries. Otherwise, make sure to use an older libc version for best compatability.
An alternative might be xgo, which may be a bit easier to cross-compile cgo code depending on what you want and personal preferences.
- Make sure you have the required C compiler cross-build tools installed;
you can usually install these from your distro's package manger (names
vary; searching for
-
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.