Skip to content

mogharsallah/goreleaser

 
 

Repository files navigation

GoReleaser

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 [email protected].

Release Software License Travis Go Report Card Powered By: GoReleaser

Why?

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_TOKEN environment variable with the repo scope 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 goreleaser at 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.

Of course, all this can be customized!

Customization

For customization create a goreleaser.yml file in the root of your repository.

A complete and commented example can be found here.

You can also check the goreleaser.yml used by GoReleaser itself.

A note about 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.

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