github.com/szyn/goreleaser@v0.76.1-0.20180517112710-333da09a1297/www/content/environment.md (about) 1 --- 2 title: Environment 3 weight: 20 4 menu: true 5 --- 6 7 ## GitHub Token 8 9 GoReleaser requires a GitHub API token with the `repo` scope selected to 10 deploy the artifacts to GitHub. 11 You can create one [here](https://github.com/settings/tokens/new). 12 13 This token should be added to the environment variables as `GITHUB_TOKEN`. 14 Here is how to do it with Travis CI: 15 [Defining Variables in Repository Settings](https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings). 16 17 Alternatively, you can provide the GitHub token in a file. GoReleaser will check `~/.config/goreleaser/github_token` by default, you can change that in 18 the `.goreleaser.yml` file: 19 20 ```yaml 21 # .goreleaser.yml 22 env_files: 23 github_token: ~/.path/to/my/token 24 ``` 25 26 ## GitHub Enterprise 27 28 You can use GoReleaser with GitHub Enterprise by providing its URLs in 29 the `.goreleaser.yml` configuration file: 30 31 ```yaml 32 # .goreleaser.yml 33 github_urls: 34 api: https://git.company.com/api/v3/ 35 upload: https://git.company.com/api/uploads/ 36 download: https://git.company.com/ 37 ``` 38 39 If none are set, they default to GitHub's public URLs. 40 41 **IMPORTANT**: be careful with the URLs, they may change from one instalation 42 to another. If they are wrong, goreleaser will fail at some point, so, make 43 sure they're right before opening an issue. See for example [#472][472]. 44 45 [472]: https://github.com/goreleaser/goreleaser/issues/472 46 47 ## The dist folder 48 49 By default, GoReleaser will create its artifacts in the `./dist` folder. 50 If you must, you can change it by setting it in the `.goreleaser.yml` file: 51 52 ```yaml 53 # .goreleaser.yml 54 dist: another-folder-that-is-not-dist 55 ``` 56 57 ## Using the `main.version` 58 59 Default wise GoReleaser sets three _ldflags_: 60 61 * `main.version`: Current Git tag (the `v` prefix is stripped) or the name of 62 the snapshot, if you're using the `--snapshot` flag 63 * `main.commit`: Current git commit SHA 64 * `main.date`: Date according [RFC3339](https://golang.org/pkg/time/#pkg-constants) 65 66 You can use it in your `main.go` file: 67 68 ```go 69 package main 70 71 import "fmt" 72 73 var ( 74 version = "dev" 75 commit = "none" 76 date = "unknown" 77 ) 78 79 func main() { 80 fmt.Printf("%v, commit %v, built at %v", version, commit, date) 81 } 82 ``` 83 84 You can override this by changing the `ldflags` option in the `build` section. 85 86 ## Customizing Git 87 88 By default, GoReleaser uses full length commit hashes when setting a `main.commit` 89 _ldflag_ or creating filenames in `--snapshot` mode. 90 91 You can use short, 7 character long commit hashes by setting it in the `.goreleaser.yml`: 92 93 ```yaml 94 # .goreleaser.yml 95 git: 96 short_hash: true 97 ```