diff --git a/README.md b/README.md index 02c515486..e0138f00f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ goreleaser -GoReleaser builds Go binaries for several platforms, creates a Github release and then +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](CODE_OF_CONDUCT.md). @@ -34,83 +34,22 @@ 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 +and finally, publish a new GitHub release in the repository with archives uploaded. +## Customization -For further customization create a `goreleaser.yml` file in the root of your repository. +For customization create a `goreleaser.yml` file in the root of your repository. -### Homebrew +A complete and commented example can be found [here](/goreleaser.example.yml). -Add a `brew` section to push a formulae to a Homebrew tab repository: +You can also check the [goreleaser.yml](/goreleaser.yml) used by GoReleaser +itself. -```yaml -brew: - repo: user/homebrew-tap - folder: optional/subfolder/inside/the/repo - caveats: "Optional caveats to add to the formulae" -``` +### A note about `main.version` -See the [Homebrew docs](https://github.com/Homebrew/brew/blob/master/docs/How-to-Create-and-Maintain-a-Tap.md) for creating your own tap. - -### Build customization - -Just add a `build` section - -```yaml -build: - main: ./cmd/main.go - ldflags: -s -w - oses: - - darwin - - freebsd - arches: - - amd64 -``` - -> - `oses` and `arches` should be in `GOOS`/`GOARCH`-compatible format. -> - `-s -w` is the default value for `ldflags`. - -### Archive customization - -You can customize the name and format of the archive adding an `archive` -section: - -```yaml -archive: - name_template: "{{.BinaryName}}_{{.Version}}_{{.Os}}_{{.Arch}}" - format: zip - replacements: - amd64: 64-bit - 386: 32-bit - darwin: macOS - linux: Tux -``` - -> - Default `name_template` is `{{.BinaryName}}_{{.Os}}_{{.Arch}}` -> - Valid formats are `tar.gz` and `zip`, default is `tar.gz` -> - By default, `replacements` replace `GOOS` with `uname -s` values and -> `GOARCH` with `uname -m` values. They keys should always be in the `GOOS` and -> `GOARCH` form. - -### Add more files - -You might also want to change the files that are packaged by adding a `files` -section: - -```yaml -files: - - LICENSE.txt - - README.md - - CHANGELOG.md -``` - -> By default GoReleaser adds the binary itself, `LICENCE*`, `LICENSE*`, -`README*` and `CHANGELOG*`. - -### ldflags (main.version) - -GoReleaser always sets a `main.version` ldflag. You can use it in your `main.go` file: +GoReleaser always sets a `main.version` ldflag. You can use it in your +`main.go` file: ```go package main @@ -124,24 +63,6 @@ func main() { 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 a `repo`: - -```yaml -repo: owner/custom-repo -``` - -- By default the binary name is the name of the project directory. - You can specify a different `binary_name`: - -```yaml -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: @@ -153,7 +74,7 @@ after_success: ## What the end result looks like -The release on Github looks pretty much like this: +The release on GitHub looks pretty much like this: [![image](https://cloud.githubusercontent.com/assets/245435/21578845/09404c8a-cf78-11e6-92d7-165ddc03ca6c.png) ](https://github.com/goreleaser/goreleaser/releases) diff --git a/goreleaser.example.yml b/goreleaser.example.yml new file mode 100644 index 000000000..f773a2753 --- /dev/null +++ b/goreleaser.example.yml @@ -0,0 +1,81 @@ +# Build customization +build: + # main.go path. + # Default is `main.go` + main: ./cmd/main.go + + # name of the binary. Default is the name of the project directory. + binary_name: program + + # custom ldflags. + # Default is `-s -w` + ldflags: -s -w + + # GOOS list to build in. + # Defaults are darwin and linux + goos: + - freebsd + - windows + + # GOARCH to build in. + # Defaults are 386 and amd64 + goarch: + - amd64 + + +# Archive customization +archive: + # You can change the name of the archive. + # This is parsed with golang template engine and the following variables + # are available: + # - BinaryName + # - Version + # - Os + # - Arch + # The default is `{{.BinaryName}}_{{.Os}}_{{.Arch}}` + name_template: "{{.BinaryName}}_{{.Version}}_{{.Os}}_{{.Arch}}" + + # Archive format. Valid options are `tar.gz` and `zip`. + # Default is `zip` + format: zip + + # Replacements for GOOS and GOARCH on the archive name. + # The left values should be a valid GOOS or GOARCH name, and the right + # the name you want instead. + # By default, replacements replace GOOS and GOARCH values with valid outputs + # of uname -s and uname -m respectively. + replacements: + amd64: 64-bit + 386: 32-bit + darwin: macOS + linux: Tux + + # Additional files you want to add to the archive. + # Defaults are any files matching `LICENCE*`, `LICENSE*`, + # `README*` and `CHANGELOG*` (case-insensitive) + files: + - LICENSE.txt + - README.md + - CHANGELOG.md + + +# Release customization +release: + # Repo in which the release will be created. + # Default is extracted from the origin remote URL. + repo: user/repo + + +# The brew section specifies how the formula should be created +# Check this link for details: https://github.com/Homebrew/brew/blob/master/docs/How-to-Create-and-Maintain-a-Tap.md +brew: + # Reporitory to push the tap + repo: user/homebrew-tap + + # Folder inside the repository to put the formula. + # Default is the root folder + folder: Formula + + # Caveats for the user of your binary. + # Default is empty. + caveats: "How to use this binary"