2017-09-10 17:07:28 -03:00
---
2017-11-26 21:55:59 -02:00
title: Environment
2018-04-24 22:20:12 -07:00
weight: 20
menu: true
2017-09-10 17:07:28 -03:00
---
2017-12-04 09:49:29 -02:00
## GitHub Token
2017-09-10 17:07:28 -03:00
2019-06-29 16:02:40 +02:00
GoReleaser requires either a GitHub API token with the `repo` scope selected to
deploy the artifacts to GitHub **or** a GitLab API token with `api` scope.
You can create one [here ](https://github.com/settings/tokens/new ) for GitHub or [here ](https://gitlab.com/profile/personal_access_tokens ) for GitLab.
2017-09-10 17:07:28 -03:00
2019-06-29 16:02:40 +02:00
This token should be added to the environment variables as `GITHUB_TOKEN` or a `GITLAB_TOKEN` respecively.
2017-09-10 17:07:28 -03:00
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 ).
2019-06-29 16:02:40 +02:00
Alternatively, you can provide the GitHub/GitLab token in a file. GoReleaser will check `~/.config/goreleaser/github_token` or `~/.config/goreleaser/gitlab_token` by default, you can change that in
2018-02-03 16:47:26 -02:00
the `.goreleaser.yml` file:
```yaml
# .goreleaser.yml
env_files:
2019-06-29 16:02:40 +02:00
# use only one or release will fail!
github_token: ~/.path/to/my/gh_token
gitlab_token: ~/.path/to/my/gl_token
2018-02-03 16:47:26 -02:00
```
2018-02-03 00:06:48 -02:00
2019-06-29 16:02:40 +02:00
**IMPORTANT**: you can define both env files, but the release process will fail
because both tokens are defined. Use only one.
2018-02-18 20:37:59 -03: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:
2018-05-08 20:43:40 -03:00
api: https://git.company.com/api/v3/
upload: https://git.company.com/api/uploads/
download: https://git.company.com/
2019-01-19 18:16:25 -02:00
# set to true if you use a self-signed certificate
skip_tls_verify: false
2018-02-18 20:37:59 -03:00
```
If none are set, they default to GitHub's public URLs.
2019-06-29 16:02:40 +02:00
## GitLab Enterprise or private hosted
You can use GoReleaser with GitHub Enterprise by providing its URLs in
the `.goreleaser.yml` configuration file:
```yaml
# .goreleaser.yml
gitlab_urls:
api: https://gitlab.mycompany.com/api/v4/
download: https://gitlab.company.com
# set to true if you use a self-signed certificate
skip_tls_verify: false
```
2018-05-08 20:43:40 -03:00
2019-06-29 16:02:40 +02:00
If none are set, they default to GitLab's public URLs.
2018-05-08 20:43:40 -03:00
2017-12-04 09:49:29 -02:00
## The dist folder
2017-11-26 21:50:49 -02:00
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
```
2017-11-26 21:58:58 -02:00
2017-12-04 09:49:29 -02:00
## Using the `main.version`
2017-11-26 21:58:58 -02:00
2018-05-06 09:19:14 -03:00
Default wise GoReleaser sets three _ldflags_ :
2018-05-06 10:44:46 +02:00
2018-05-28 10:49:38 -03:00
- `main.version` : Current Git tag (the `v` prefix is stripped) or the name of
2018-05-06 09:19:14 -03:00
the snapshot, if you're using the `--snapshot` flag
2018-05-28 10:49:38 -03:00
- `main.commit` : Current git commit SHA
- `main.date` : Date according [RFC3339 ](https://golang.org/pkg/time/#pkg-constants )
2018-05-06 10:44:46 +02:00
2017-11-26 21:58:58 -02:00
You can use it in your `main.go` file:
```go
package main
2018-05-06 10:44:46 +02:00
import "fmt"
var (
version = "dev"
commit = "none"
date = "unknown"
)
2017-11-26 21:58:58 -02:00
func main() {
2018-05-06 10:44:46 +02:00
fmt.Printf("%v, commit %v, built at %v", version, commit, date)
2017-11-26 21:58:58 -02:00
}
```
You can override this by changing the `ldflags` option in the `build` section.