1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-07 15:00:12 +02:00

docs: Polish all docs

This shortens the titles, fixes some typos, rephrases a few paragraphs,
adds some additional information and attempts to keep vocabulary more
consistent.
This commit is contained in:
Jorin Vogel 2017-10-01 18:57:52 +02:00
parent ef68fce2a8
commit c04b18a289
No known key found for this signature in database
GPG Key ID: 647AFD30D56CE8CC
18 changed files with 192 additions and 175 deletions

@ -3,7 +3,7 @@ title: Introduction
---
[GoReleaser](https://github.com/goreleaser/goreleaser) is a release automation
tool for Golang projects, the goal is to simplify the build, release and
tool for Go projects, the goal is to simplify the build, release and
publish steps while providing variant customization options for all steps.
GoReleaser is built for CI tools; you only need to
@ -14,5 +14,5 @@ creating a `.goreleaser.yml` file.
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
Homebrew taps, which would made the script even more hacky, so I let go of
Homebrew taps, which would have made the script even more hacky, so I let go of
that and rewrote the whole thing in Go.

@ -2,7 +2,8 @@
title: Quick Start
---
In this example we will build, archive and release a Golang project.
In this example we will build, archive and release a Go project.
Create a GitHub repository and add a single main package:
```go
@ -15,7 +16,7 @@ func main() {
```
By default GoReleaser will build the current directory, but you can change
the build package path in the GoReleaser configuration file.
the package path in the GoReleaser configuration file:
```yml
# .goreleaser.yml
@ -30,17 +31,17 @@ builds:
- amd64
```
PS: Invalid GOOS/GOARCH combinations will automatically be skipped.
GoReleaser skips invalid GOOS/GOARCH combinations.
This configuration specifies the build operating systems to Windows, Linux and
MacOS using 64bit architecture, the name of the binaries is `drum-roll`.
With the above configuration the name of all created binaries will be `drum-roll`
and GoReleaser will build one binary in 64bit architecture for each of the operating systems Windows, Linux and MacOS.
GoReleaser will then archive the result binaries of each Os/Arch into a
GoReleaser will then archive the resulting binaries of each OS/Arch pair into a
separate file. The default format is `{{.ProjectName}}_{{.Os}}_{{.Arch}}`.
You can change the archives name and format. You can also replace the OS
You can change the archive's name and format. You can also replace the OS
and the Architecture with your own.
Another useful feature is to add files to archives, this is very useful for
integrating assets like resource files.
Another useful feature is to add additional files to the created archives:
```yml
# .goreleaser.yml
@ -65,17 +66,18 @@ archive:
- drum-roll.licence.txt
```
This configuration will generate tar archives, containing an additional
file called `drum-roll.licence.txt`. The archives will be located in the `dist``
folder:
This configuration will generate `tar` archives, each containing an additional
file called `drum-roll.licence.txt`.
The archives will be located in the `dist` folder:
- `./dist/drum-roll_windows_64-bit.tar.gz`
- `./dist/drum-roll_macOS_64-bit.tar.gz`
- `./dist/drum-roll_Tux_64-bit.tar.gz`
Next export a `GITHUB_TOKEN` environment variable with the `repo` scope
selected. This will be used to deploy releases to your GitHub repository.
Create yours [here](https://github.com/settings/tokens/new).
Next, you need to export a `GITHUB_TOKEN` environment variable, which should contain a
GitHub token with the `repo` scope selected.
It will be used to deploy releases to your GitHub repository.
Create a token [here](https://github.com/settings/tokens/new).
```console
$ export GITHUB_TOKEN=`YOUR_TOKEN`
@ -93,10 +95,10 @@ $ git push origin v0.1.0
**Note**: We recommend the use of [semantic versioning](http://semver.org/). We
are not enforcing it though. We do remove the `v` prefix and then enforce
that the next character is a number. So, `v0.1.0` and `0.1.0` are virtually the
same and are both accepted, while `version0.1.0` is not.
same and both are accepted, while `version0.1.0` is not.
If you don't want to create a tag yet but instead simply create a package
based on the latest commit, then you can also use the `--snapshot` flag.
If you don't want to create a tag yet, you can also create a release
based on the latest commit by using the `--snapshot` flag.
Now you can run GoReleaser at the root of your repository:
@ -104,7 +106,7 @@ Now you can run GoReleaser at the root of your repository:
$ goreleaser
```
That's it! Check your GitHub project's release page.
That's all! Check your GitHub project's release page.
The release should look like this:
<a href="https://github.com/goreleaser/goreleaser/releases">

@ -1,33 +1,14 @@
---
title: Environment Setup
title: Environment Variables
---
### GitHub Token
GoReleaser requires a GitHub API token with the `repo` scope checked to
deploy the artefacts to GitHub. You can create one
[here](https://github.com/settings/tokens/new).
GoReleaser requires a GitHub API token with the `repo` scope selected to
deploy the artifacts to GitHub.
You can create one [here](https://github.com/settings/tokens/new).
This token should be added to the environment variables as `GITHUB_TOKEN`.
Here is how to do it with Travis CI:
[Defining Variables in Repository Settings](https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings).
### A note about `main.version`
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)
}
```
`version` will be the current Git tag (with `v` prefix stripped) or the name of
the snapshot if you're using the `--snapshot` flag.
You can override this by changing the `ldflags` option in the `build` section.

21
docs/025-version.md Normal file

@ -0,0 +1,21 @@
---
title: `main.version`
---
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)
}
```
`version` will be set to the current Git tag (the `v` prefix is stripped) or the name of
the snapshot, if you're using the `--snapshot` flag.
You can override this by changing the `ldflags` option in the `build` section.

@ -3,7 +3,7 @@ title: Customization
---
GoReleaser provides multiple customizations via the `.goreleaser.yml` file.
You can generate it by running `goreleaser init` or start from scratch. The
defaults are sensible and fit for most projects.
You can generate it by running `goreleaser init` or start from scratch.
The defaults are sensible and fit for most projects.
We'll cover all customizations available bellow.

@ -1,9 +1,9 @@
---
title: Custom project name
title: Project Name
---
The project name is used in the name of the brew formula, archives, etc.
If none is given, it will be infered from the name of the git project.
The project name is used in the name of the Brew formula, archives, etc.
If none is given, it will be inferred from the name of the Git project.
```yaml

@ -1,63 +1,63 @@
---
title: Custom builds
title: Builds
---
Builds can be customized in multiple ways. You can change which `GOOS` and
`GOARCH` would be built, the name of the binary, flags, ldflags, hooks and etc.
Builds can be customized in multiple ways. You can specify for which `GOOS` and
`GOARCH` binaries are generated, and you can changed the name of the binary, flags, `ldflags`, hooks, etc.
Here is a full commented `builds` section:
Here is a commented `builds` section with all fields specified:
```yml
# .goreleaser.yml
builds:
# You can have multiple builds defined as a common yaml list
# You can have multiple builds defined as a yaml list
-
# Path to main.go file or main package.
# Default is `.`
# Default is `.`.
main: ./cmd/main.go
# Name of the binary.
# Default is the name of the project directory.
binary: program
# Custom build tags.
# Default is empty
# Set flags for custom build tags.
# Default is empty.
flags: -tags dev
# Custom ldflags template.
# This is parsed with Golang template engine and the following variables
# This is parsed with the Go template engine and the following variables
# are available:
# - Date
# - Commit
# - Tag
# - Version (Tag with the `v` prefix stripped)
# The default is `-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}`
# Date format is `2006-01-02_15:04:05`
# - Version (Git tag without `v` prefix)
# Date format is `2006-01-02_15:04:05`.
# Default is `-s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}`.
ldflags: -s -w -X main.build={{.Version}}
# Custom environment variables to be set durign the builds.
# Default is empty
# Custom environment variables to be set during the builds.
# Default is empty.
env:
- CGO_ENABLED=0
# GOOS list to build in.
# For more info refer to https://golang.org/doc/install/source#environment
# Defaults are darwin and linux
# GOOS list to build for.
# For more info refer to: https://golang.org/doc/install/source#environment
# Defaults are darwin and linux.
goos:
- freebsd
- windows
# GOARCH to build in.
# For more info refer to https://golang.org/doc/install/source#environment
# Defaults are 386 and amd64
# GOARCH to build for.
# For more info refer to: https://golang.org/doc/install/source#environment
# Defaults are 386 and amd64.
goarch:
- amd64
- arm
- arm64
# GOARM to build in when GOARCH is arm.
# For more info refer to https://golang.org/doc/install/source#environment
# Defaults are 6
# GOARM to build for when GOARCH is arm.
# For more info refer to: https://golang.org/doc/install/source#environment
# Default is only 6.
goarm:
- 6
- 7
@ -71,8 +71,8 @@ builds:
goarch: arm
goarm: 7
# Hooks can be used to customize the final binary, for example, to run
# generator or whatever you want.
# Hooks can be used to customize the final binary,
# for example, to run generators.
# Default is both hooks empty.
hooks:
pre: rice embed-go

@ -1,44 +1,45 @@
---
title: Custom archiving
title: Archive
---
The binaries built will be archived within the README and LICENSE files into a
The binaries built will be archived together with the `README` and `LICENSE` files into a
`tar.gz` file. In the `archive` section you can customize the archive name,
files, and format.
additional files, and format.
Here is a full commented `archive` section:
Here is a commented `archive` section with all fields specified:
```yml
# .goreleaser.yml
archive:
# You can change the name of the archive.
# This is parsed with Golang template engine and the following variables
# This is parsed with the Go template engine and the following variables
# are available:
# - ProjectName
# - Tag
# - Version (Tag with the `v` prefix stripped)
# - Version (Git tag without `v` prefix)
# - Os
# - Arch
# - Arm (ARM version)
# The default is `{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}`
# Default is `{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}`.
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
# Archive format. Valid options are `tar.gz`, `zip` and `binary`.
# If format is `binary` no archives are created and the binaries are instead uploaded directly.
# In that case name_template the below specified files are ignored.
# Default is `tar.gz`
# If format is `binary`, no archives are created and the binaries are instead uploaded directly.
# In that case name_template and the below specified files are ignored.
# Default is `tar.gz`.
format: zip
# Can be used to archive on different formats for specific GOOSs.
# Can be used to change the archive formats for specific GOOSs.
# Most common use case is to archive as zip on Windows.
# Default is empty
# Default is empty.
format_overrides:
- goos: windows
format: zip
# Replacements for GOOS and GOARCH on the archive name.
# The keys should be valid GOOS or GOARCH values followed by your custom
# replacements.
# Replacements for GOOS and GOARCH in the archive name.
# Keys should be valid GOOSs or GOARCHs.
# Values are the respective replacements.
# Default is empty.
replacements:
amd64: 64-bit
386: 32-bit
@ -47,7 +48,7 @@ archive:
# Additional files/globs you want to add to the archive.
# Defaults are any files matching `LICENCE*`, `LICENSE*`,
# `README*` and `CHANGELOG*` (case-insensitive)
# `README*` and `CHANGELOG*` (case-insensitive).
files:
- LICENSE.txt
- README.md

@ -1,22 +1,21 @@
---
title: Custom checksum
title: Checksum
---
GoRelease generates a `project_1.0.0_checksums.txt` and uploads it to the
release as well, so your users can validate if the downloaded files are
right.
GoReleaser generates a `project_1.0.0_checksums.txt` file and uploads it with the
release, so your users can validate if the downloaded files are correct.
The `checksum` section allows the customization of the filename:
The `checksum` section allows customizations of the filename:
```yml
# .goreleaser.yml
checksum:
# You can change the name of the checksums file.
# This is parsed with Golang template engine and the following variables
# This is parsed with the Go template engine and the following variables
# are available:
# - ProjectName
# - Tag
# - Version (Tag with the `v` prefix stripped)
# The default is `{{ .ProjectName }}_{{ .Version }}_checksums.txt`
# - Version (Git tag without `v` prefix)
# Default is `{{ .ProjectName }}_{{ .Version }}_checksums.txt`.
name_template: "{{ .ProjectName }}_checksums.txt"
```

@ -2,10 +2,10 @@
title: Snapshots
---
Sometimes we want to generate a full build of our project for some reason,
but don't want to validate anything nor upload it to anywhere.
GoRelease supports this with a `--snapshot` flag and with a `snapshot`
customization section as well.
Sometimes we want to generate a full build of our project,
but neither want to validate anything nor upload it to anywhere.
GoReleaser supports this with the `--snapshot` flag
and also with the `snapshot` customization section:
```yml
# .goreleaser.yml
@ -15,6 +15,6 @@ snapshot:
# - Commit
# - Tag
# - Timestamp
# Default: SNAPSHOT-{{.Commit}}
# Default is `SNAPSHOT-{{.Commit}}`.
name_template: SNAPSHOT-{{.Commit}}
```

@ -1,5 +1,5 @@
---
title: Custom linux packages
title: FPM Linux Packages
---
GoReleaser can be wired to [fpm](https://github.com/jordansissel/fpm) to
@ -9,44 +9,45 @@ generate `.deb`, `.rpm` and other archives. Check its
```yml
# .goreleaser.yml
fpm:
# Your app's vendor
# Default is empty
# Your app's vendor.
# Default is empty.
vendor: Drum Roll Inc.
# Your app's homepage
# Default is empty
# Your app's homepage.
# Default is empty.
homepage: https://example.com/
# Your app's maintainer (probably you)
# Default is empty
# Your app's maintainer (probably you).
# Default is empty.
maintainer: Drummer <drum-roll@example.com>
# Your app's description
# Default is empty
# Your app's description.
# Default is empty.
description: Software to create fast and easy drum rolls.
# Your app's license
# Default is empty
# Your app's license.
# Default is empty.
license: Apache 2.0
# Formats to generate as output
# Formats to be generated.
formats:
- deb
- rpm
# Dependencies of your package
# Packages your package depends on.
dependencies:
- git
- zsh
# Packages that conflict with your package
# Packages that conflict with your package.
conflicts:
- svn
- bash
# Files or directories to add to your package (beyond the binary)
# Files or directories to add to your package (beyond the binary).
# Keys are source paths to get the files from.
# Values are the destination locations of the files in the package.
files:
"scripts/etc/init.d/": "/etc/init.d"
```
Note that GoReleaser will not install `fpm` nor any of its dependencies for you.
Note that GoReleaser will not install `fpm` or any of its dependencies for you.

@ -1,9 +1,9 @@
---
title: Snapcraft packaging
title: Snapcraft Linux Packages
---
GoReleaser can generate `snap` packages. [Snaps](http://snapcraft.io/) are a
new packaging format that will let you publish your project directly to the
new packaging format, that will let you publish your project directly to the
Ubuntu store. From there it will be installable in all the
[supported Linux distros](https://snapcraft.io/docs/core/install), with
automatic and transactional updates.
@ -14,7 +14,8 @@ You can read more about it in the [snapcraft docs](https://snapcraft.io/docs/).
# .goreleaser.yml
snapcraft:
# The name of the snap. This is optional and defaults to the project name.
# The name of the snap. This is optional.
# Default is project name.
name: drumroll
# Single-line elevator pitch for your amazing snap.
@ -34,7 +35,7 @@ snapcraft:
# `devel` will let you release only to the `edge` and `beta` channels in the
# store. `stable` will let you release also to the `candidate` and `stable`
# channels. More info about channels here:
# https://snapcraft.io/docs/reference/channels.
# https://snapcraft.io/docs/reference/channels
grade: stable
# Snaps can be setup to follow three different confinement policies:
@ -42,14 +43,14 @@ snapcraft:
# can only read and write in its own namespace is recommended. Extra
# permissions for strict snaps can be declared as `plugs` for the app, which
# are explained later. More info about confinement here:
# https://snapcraft.io/docs/reference/confinement).
# https://snapcraft.io/docs/reference/confinement
confinement: strict
# Each binary built by GoReleaser is an app inside the snap. In this section
# you can declare extra details for those binaries. It is optional.
apps:
# The name of the app must be the same name of the binary built.
# The name of the app must be the same name as the binary built.
drumroll:
# If your app requires extra permissions to work outside of its default

@ -1,10 +1,9 @@
---
title: Custom releasing
title: Releasing
---
GoRelease will create a release in GitHub with the current tag, upload all
the archives and checksums, also generating a changelog from the commit
log between the current and previous tags.
GoReleaser will create a release in GitHub with the current tag, upload all
the archives and checksums, also generate a changelog from the commits new since the last tag.
Let's see what can be customized in the `release` section:
@ -18,16 +17,17 @@ release:
name: repo
# If set to true, will not auto-publish the release.
# Default is false
# Default is false.
draft: true
```
## Custom release notes
You can have a markdown file previously created with the release notes, and
pass it down to goreleaser with the `--release-notes=FILE` flag.
You can specify a file containing your custom release notes, and
pass it with the `--release-notes=FILE` flag.
GoReleaser will then skip its own release notes generation,
using the contents of your file instead.
You can use Markdown to format the contents of your file.
On Unix systems you can also generate the release notes in-line by using [process substitution](https://en.wikipedia.org/wiki/Process_substitution).
To list all commits since the last tag, but skip ones starting with `Merge` or `docs`, you could run this command:

@ -1,11 +1,11 @@
---
title: Custom homebrew tap
title: Homebrew
---
After releasing to GitHub, GoReleaser can generate and publish a homebrew-tap
After releasing to GitHub, GoReleaser can generate and publish a *homebrew-tap*
recipe into a repository that you have access to.
The brew section specifies how the formula should be created.
The `brew` section specifies how the formula should be created.
You can check the
[Homebrew documentation](https://github.com/Homebrew/brew/blob/master/docs/How-to-Create-and-Maintain-a-Tap.md)
and the
@ -21,6 +21,7 @@ brew:
name: homebrew-tap
# Git author used to commit to the repository.
# Defaults are shown.
commit_author:
name: goreleaserbot
email: goreleaser@carlosbecker.com
@ -33,35 +34,38 @@ brew:
# Default is empty.
caveats: "How to use this binary"
# Your app's homepage
# Default is empty
# Your app's homepage.
# Default is empty.
homepage: "https://example.com/"
# Your app's description
# Default is empty
# Your app's description.
# Default is empty.
description: "Software to create fast and easy drum rolls."
# Dependencies of your package
# Packages your package depends on.
dependencies:
- git
- zsh
# Packages that conflict with your package
# Packages that conflict with your package.
conflicts:
- svn
- bash
# Packages that run as a service. Default is empty.
# Specify for packages that run as a service.
# Default is empty.
plist: |
<?xml version="1.0" encoding="UTF-8"?>
...
# So you can brew test your formula. Default is empty.
# So you can `brew test` your formula.
# Default is empty.
test: |
system "#{bin}/program --version"
...
# Custom install script for brew. Default is 'bin.install "program"'
# Custom install script for brew.
# Default is 'bin.install "program"'.
install: |
bin.install "program"
...
@ -69,7 +73,7 @@ brew:
By defining the `brew` section, GoReleaser will take care of publishing the
Homebrew tap.
Assuming that the current tag is `v1.2.3`, the above config will generate a
Assuming that the current tag is `v1.2.3`, the above configuration will generate a
`program.rb` formula in the `Formula` folder of `user/homebrew-tap` repository:
```rb

@ -1,25 +1,25 @@
---
title: Docker Support
title: Docker
---
Since [v0.31.0](https://github.com/goreleaser/goreleaser/releases/tag/v0.31.0),
[GoReleaser](https://github.com/goreleaser/goreleaser) support building and
pushing Docker images.
GoReleaser supports building and pushing Docker images.
## How it works
You can declare multiple Docker images. They will be matched against your
You can declare multiple Docker images. They will be matched against
the binaries generated by your `builds` section.
If you have only one `build` setup, the config is as easy as adding the
name of your image to your `.goreleaser.yml`:
If you have only one `build` setup,
the configuration is as easy as adding the
name of your image to your `.goreleaser.yml` file:
```yaml
dockers:
- image: user/repo
```
You also need to create a `Dockerfile` in your repo root folder:
You also need to create a `Dockerfile` in your project's root folder:
```dockerfile
FROM scratch
@ -27,37 +27,37 @@ COPY mybin /
ENTRYPOINT ["/mybin"]
```
This config will build and push a docker image named `user/repo:tagname`.
This configuration will build and push a Docker image named `user/repo:tagname`.
## Customization
Of course, you can customize a lot of things out of this:
Of course, you can customize a lot of things:
```yaml
# .goreleaser.yml
dockers:
# You can have multiple Docker images
# You can have multiple Docker images.
-
# GOOS of the built binary that should be used
# GOOS of the built binary that should be used.
goos: linux
# GOARCH of the built binary that should be used
# GOARCH of the built binary that should be used.
goarch: amd64
# GOARM of the built binary that should be used
# GOARM of the built binary that should be used.
goarm: ''
# Name of the built binary that should be used
# Name of the built binary that should be used.
binary: mybinary
# Docker image name
# Docker image name.
image: myuser/myimage
# Path to the Dockerfile (from the project root)
# Path to the Dockerfile (from the project root).
dockerfile: Dockerfile
# Also tag and push myuser/myimage:latest
# Also tag and push myuser/myimage:latest.
latest: true
# If your dockerfile copies more files other than the binary itself,
# If your Dockerfile copies files other than the binary itself,
# you should list them here as well.
extra_files:
- config.yml
```
These settings should allow you to generate multiple docker images, using
multiple `FROM` statements, for example, as well generate one image for
each binary in your project.
These settings should allow you to generate multiple Docker images,
for example, using multiple `FROM` statements,
as well as generate one image for each binary in your project.

@ -1,8 +1,8 @@
---
title: CI integration
title: Continous Integration
---
You may want to wire this to auto-deploy your new tags on
You may want to setup your project to auto-deploy your new tags on
[Travis](https://travis-ci.org), for example:
```yaml
@ -23,5 +23,12 @@ deployment:
- curl -sL https://git.io/goreleaser | bash
```
**Note**: If you test multiple versions or multiple OSes you probably want to
If you test multiple versions or multiple OSes, you probably want to
make sure GoReleaser is just run once.
You could change the above example for Travis CI like this:
```yaml
# .travis.yml
after_success:
- test "$TRAVIS_OS_NAME" = "linux" -a -n "$TRAVIS_TAG" && curl -sL https://git.io/goreleaser | bash
```

@ -1,8 +1,8 @@
---
title: GitHub Enterprise Support
title: GitHub Enterprise
---
You can use GitHub Enteprise within GoReleaser by providing its URLs in
You can use GoReleaser with GitHub Enterprise by providing its URLs in
the `.goreleaer.yml` configuration file:
```yaml
@ -13,4 +13,4 @@ github_urls:
download: github.foo.bar
```
If none is set, it will default to the public GitHub's URLs.
If none are set, they default to GitHub's public URLs.

@ -2,10 +2,10 @@
title: Links
---
- Follow the progress on [GitHub repository](https://github.com/goreleaser/goreleaser)
- Follow the progress on the [GitHub repository](https://github.com/goreleaser/goreleaser)
- Follow [@caarlos0](https://twitter.com/caarlos0) on Twitter for updates
- [Slack](https://gophers.slack.com/messages/goreleaser/) to chat about GoReleaser,
questions and etc. Join using [this link](https://invite.slack.golangbridge.org/).
questions, etc. Join using [this link](https://invite.slack.golangbridge.org/)
- [Contributing Guidelines](https://github.com/goreleaser/goreleaser/blob/master/CONTRIBUTING.md)
This project adheres to the Contributor Covenant