1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-16 03:52:12 +02:00
goreleaser/README.md

115 lines
4.0 KiB
Markdown
Raw Normal View History

2017-01-14 15:01:45 +02:00
# GoReleaser
2016-12-29 17:49:01 +02:00
2017-01-12 02:59:59 +02:00
<img src="https://avatars2.githubusercontent.com/u/24697112?v=3&s=200" alt="goreleaser" align="right" />
2016-12-29 21:55:07 +02:00
2017-01-14 23:24:25 +02:00
GoReleaser builds Go binaries for several platforms, creates a GitHub release and then
2017-01-14 20:58:51 +02:00
pushes a Homebrew formulae to a repository. All that wrapped in your favorite CI.
2016-12-29 17:49:01 +02:00
2017-01-02 17:40:15 +02:00
This project adheres to the Contributor Covenant [code of conduct](CODE_OF_CONDUCT.md).
By participating, you are expected to uphold this code. Please report unacceptable behavior to root@carlosbecker.com.
2017-01-15 13:04:12 +02:00
[![Release](https://img.shields.io/github/release/goreleaser/goreleaser.svg?style=flat-square)](https://github.com/goreleaser/goreleaser/releases/latest)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Travis](https://img.shields.io/travis/goreleaser/goreleaser.svg?style=flat-square)](https://travis-ci.org/goreleaser/goreleaser)
[![Go Report Card](https://goreportcard.com/badge/github.com/goreleaser/goreleaser?style=flat-square)](https://goreportcard.com/report/github.com/goreleaser/goreleaser)
[![Powered By: GoReleaser](https://img.shields.io/badge/powered%20by-goreleaser-green.svg?style=flat-square)](https://github.com/goreleaser)
2017-01-13 13:10:36 +02:00
2017-01-15 19:58:45 +02:00
## Why?
2016-12-29 17:49:01 +02:00
The idea started with a [simple shell script](https://github.com/goreleaser/old-go-releaser),
but it quickly became more complex and I also wanted to publish binaries via
2017-01-14 20:30:14 +02:00
Homebrew.
2016-12-29 17:49:01 +02:00
2017-01-14 22:55:24 +02:00
So, the all-new GoReleaser was born.
2016-12-29 17:49:01 +02:00
## Usage
2017-01-14 20:58:51 +02:00
- You need to export a `GITHUB_TOKEN` environment variable with
the `repo` scope selected. You can create one [here](https://github.com/settings/tokens/new).
2017-01-14 20:58:51 +02:00
- GoReleaser uses the latest [Git tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging) of your repository,
2017-01-14 15:01:45 +02:00
so you need to [create a tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging#Annotated-Tags) first.
2017-01-14 22:55:24 +02:00
- Now you can run `goreleaser` at the root of your repository:
2017-01-14 20:30:14 +02:00
```sh
curl -s https://raw.githubusercontent.com/goreleaser/get/master/latest | bash
```
This will build `main.go` as binary, for `Darwin` and `Linux`
2017-01-11 18:59:06 +02:00
(`amd64` and `i386`), archive the binary and common files as `.tar.gz`,
2017-01-14 23:24:25 +02:00
and finally, publish a new GitHub release in the repository with
2017-01-11 18:59:06 +02:00
archives uploaded.
2016-12-29 17:49:01 +02:00
2017-01-15 19:58:45 +02:00
Of course, all this can be customized!
2017-01-14 23:24:25 +02:00
## Customization
2017-01-14 20:30:14 +02:00
2017-01-14 23:24:25 +02:00
For customization create a `goreleaser.yml` file in the root of your repository.
2017-01-14 20:30:14 +02:00
2017-01-14 23:24:25 +02:00
A complete and commented example can be found [here](/goreleaser.example.yml).
2016-12-29 17:49:01 +02:00
2017-01-14 23:24:25 +02:00
You can also check the [goreleaser.yml](/goreleaser.yml) used by GoReleaser
itself.
2016-12-29 17:49:01 +02:00
2017-01-14 23:24:25 +02:00
### A note about `main.version`
2016-12-29 17:49:01 +02:00
2017-01-14 23:24:25 +02:00
GoReleaser always sets a `main.version` ldflag. You can use it in your
`main.go` file:
```go
package main
var version = "master"
func main() {
println(version)
}
```
2017-01-14 20:58:51 +02:00
And this version will always be the name of the current tag.
2017-01-14 20:58:51 +02:00
## Wire it with Travis CI
2016-12-29 17:49:01 +02:00
2017-01-14 20:58:51 +02:00
You may want to wire this to auto-deploy your new tags on Travis, for example:
2016-12-29 17:49:01 +02:00
```yaml
after_success:
2017-01-02 17:57:36 +02:00
test -n "$TRAVIS_TAG" && curl -s https://raw.githubusercontent.com/goreleaser/get/master/latest | bash
2016-12-29 17:49:01 +02:00
```
2017-01-04 11:35:04 +02:00
## What the end result looks like
2016-12-29 17:49:01 +02:00
2017-01-14 23:24:25 +02:00
The release on GitHub looks pretty much like this:
2016-12-29 17:49:01 +02:00
2016-12-31 20:45:16 +02:00
[![image](https://cloud.githubusercontent.com/assets/245435/21578845/09404c8a-cf78-11e6-92d7-165ddc03ca6c.png)
2017-01-14 22:52:57 +02:00
](https://github.com/goreleaser/goreleaser/releases)
2016-12-29 17:49:01 +02:00
2017-01-14 20:30:14 +02:00
And the [Homebrew formulae](https://github.com/goreleaser/homebrew-tap/blob/master/release.rb) would look like:
2016-12-29 17:49:01 +02:00
```rb
2016-12-31 20:45:16 +02:00
class Release < Formula
2017-01-11 18:52:30 +02:00
desc "Deliver Go binaries as fast and easily as possible"
2017-01-14 22:52:57 +02:00
homepage "https://github.com/goreleaser/goreleaser"
url "https://github.com/goreleaser/goreleaser/releases/download/v0.2.8/release_Darwin_x86_64.tar.gz"
2017-01-11 18:52:30 +02:00
version "v0.2.8"
sha256 "9ee30fc358fae8d248a2d7538957089885da321dca3f09e3296fe2058e7fff74"
2016-12-29 17:49:01 +02:00
def install
2016-12-31 20:45:16 +02:00
bin.install "release"
2016-12-29 17:49:01 +02:00
end
end
```
2016-12-30 01:49:58 +02:00
2017-01-02 19:08:49 +02:00
## How to contribute
Please refer to our [contributing guidelines](/CONTRIBUTING.md).
2016-12-30 01:49:58 +02:00
## Badges
Feel free to use it in your own projects:
```md
[![Powered By: GoReleaser](https://img.shields.io/badge/powered%20by-goreleaser-green.svg?style=flat-square)](https://github.com/goreleaser)
```