1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/www/content/environment.md

98 lines
2.5 KiB
Markdown
Raw Normal View History

2017-09-10 22:07:28 +02:00
---
title: Environment
weight: 20
menu: true
2017-09-10 22:07:28 +02:00
---
## GitHub Token
2017-09-10 22:07:28 +02:00
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).
2017-09-10 22:07:28 +02:00
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).
2018-02-03 20:47:26 +02:00
Alternatively, you can provide the GitHub token in a file. GoReleaser will check `~/.config/goreleaser/github_token` by default, you can change that in
the `.goreleaser.yml` file:
```yaml
# .goreleaser.yml
env_files:
github_token: ~/.path/to/my/token
```
2018-02-03 04:06:48 +02:00
2018-02-19 01:37:59 +02:00
## GitHub Enterprise
You can use GoReleaser with GitHub Enterprise by providing its URLs in
the `.goreleaser.yml` configuration file:
```yaml
# .goreleaser.yml
github_urls:
api: https://git.company.com/api/v3/
upload: https://git.company.com/api/uploads/
download: https://git.company.com/
2018-02-19 01:37:59 +02:00
```
If none are set, they default to GitHub's public URLs.
**IMPORTANT**: be careful with the URLs, they may change from one instalation
to another. If they are wrong, goreleaser will fail at some point, so, make
sure they're right before opening an issue. See for example [#472][472].
[472]: https://github.com/goreleaser/goreleaser/issues/472
## The dist folder
By default, GoReleaser will create its artifacts in the `./dist` folder.
If you must, you can change it by setting it in the `.goreleaser.yml` file:
```yaml
# .goreleaser.yml
dist: another-folder-that-is-not-dist
```
## Using the `main.version`
2018-05-06 14:19:14 +02:00
Default wise GoReleaser sets three _ldflags_:
2018-05-06 14:19:14 +02:00
* `main.version`: Current Git tag (the `v` prefix is stripped) or the name of
the snapshot, if you're using the `--snapshot` flag
* `main.commit`: Current git commit SHA
* `main.date`: Date according [RFC3339](https://golang.org/pkg/time/#pkg-constants)
You can use it in your `main.go` file:
```go
package main
import "fmt"
var (
version = "dev"
commit = "none"
date = "unknown"
)
func main() {
fmt.Printf("%v, commit %v, built at %v", version, commit, date)
}
```
You can override this by changing the `ldflags` option in the `build` section.
## Customizing Git
By default, GoReleaser uses full length commit hashes when setting a `main.commit`
_ldflag_ or creating filenames in `--snapshot` mode.
You can use short, 7 character long commit hashes by setting it in the `.goreleaser.yml`:
```yaml
# .goreleaser.yml
git:
short_hash: true
```