GoReleaser
GoReleaser builds Go binaries for several platforms, creates a Github release and then pushes a Homebrew formulae to a repository. All that wrapped in your favorite CI.
This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to root@carlosbecker.com.
How it works?
The idea started with a simple shell script, but it quickly became more complex and I also wanted to publish binaries via Homebrew.
So, the all-new goreleaser was born.
Usage
- 
You need to export a GITHUB_TOKENenvironment variable with thereposcope selected. You can create one here.
- 
GoReleaser uses the latest Git tag of your repository, so you need to create a tag first. 
- 
Now you can run releaserat the root of your repository:
curl -s https://raw.githubusercontent.com/goreleaser/get/master/latest | bash
This will build main.go as binary, for Darwin and Linux
(amd64 and i386), archive the binary and common files as .tar.gz,
and finally, publish a new Github release in the repository with
archives uploaded.
For further customization create a goreleaser.yml file in the root of your repository.
Homebrew
Add a brew section to push a formulae to a Homebrew tab repository:
brew:
  repo: user/homebrew-tap
  folder: optional/subfolder/inside/the/repo
  caveats: "Optional caveats to add to the formulae"
See the Homebrew docs for creating your own tap.
Build customization
Just add a build section
build:
  main: ./cmd/main.go
  ldflags: -s -w
  oses:
    - darwin
    - freebsd
  arches:
    - amd64
osesandarchesshould be inGOOS/GOARCH-compatible format.
-s -wis the default value forldflags.
Archive customization
You can customize the name and format of the archive adding an archive
section:
archive:
  name_template: "{{.BinaryName}}_{{.Version}}_{{.Os}}_{{.Arch}}"
  format: zip
  replacements:
    amd64: 64-bit
    386: 32-bit
    darwin: macOS
    linux: Tux
- Default
name_templateis{{.BinaryName}}_{{.Os}}_{{.Arch}}- Valid formats are
tar.gzandzip, default istar.gz- By default,
replacementsreplaceGOOSwithuname -svalues andGOARCHwithuname -mvalues. They keys should always be in theGOOSandGOARCHform.
Add more files
You might also want to change the files that are packaged by adding a files
section:
files:
  - LICENSE.txt
  - README.md
  - CHANGELOG.md
By default GoReleaser adds the binary itself,
LICENCE*,LICENSE*,README*andCHANGELOG*.
ldflags (main.version)
GoReleaser always sets a main.version ldflag. You can use it in your main.go file:
package main
var version = "master"
func main() {
  println(version)
}
And this version will always be the name of the current tag.
Other customizations
- By default it's assumed that the repository to release to is the same as the Git remote origin. If this is not the case for your project, you can specify arepo:
repo: owner/custom-repo
- By default the binary name is the name of the project directory.
You can specify a different binary_name:
binary_name: my-binary
Wire it with Travis CI
You may want to wire this to auto-deploy your new tags on Travis, for example:
after_success:
  test -n "$TRAVIS_TAG" && curl -s https://raw.githubusercontent.com/goreleaser/get/master/latest | bash
What the end result looks like
The release on Github looks pretty much like this:
And the Homebrew formulae would look like:
class Release < Formula
  desc "Deliver Go binaries as fast and easily as possible"
  homepage "https://github.com/goreleaser/goreleaser"
  url "https://github.com/goreleaser/goreleaser/releases/download/v0.2.8/release_Darwin_x86_64.tar.gz"
  version "v0.2.8"
  sha256 "9ee30fc358fae8d248a2d7538957089885da321dca3f09e3296fe2058e7fff74"
  def install
    bin.install "release"
  end
end
How to contribute
Please refer to our contributing guidelines.
Badges
Feel free to use it in your own projects:
[](https://github.com/goreleaser)
