github.com/joselitofilho/goreleaser@v0.155.1-0.20210123221854-e4891856c593/www/docs/environment.md (about)

     1  ---
     2  title: Environment
     3  ---
     4  
     5  ## API Tokens
     6  
     7  GoReleaser requires either a GitHub API token with the `repo` scope selected to
     8  deploy the artifacts to GitHub **or** a GitLab API token with `api` scope **or** a Gitea API token.
     9  You can create one [here](https://github.com/settings/tokens/new) for GitHub
    10  or [here](https://gitlab.com/profile/personal_access_tokens) for GitLab
    11  or in `Settings | Applications | Generate New Token` page of your Gitea instance.
    12  
    13  This token should be added to the environment variables as `GITHUB_TOKEN` or `GITLAB_TOKEN` or `GITEA_TOKEN` respecively.
    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/GitLab token in a file.
    18  GoReleaser will check `~/.config/goreleaser/github_token`, `~/.config/goreleaser/gitlab_token`
    19  and `~/.config/goreleaser/gitea_token` by default, you can change that in
    20  the `.goreleaser.yml` file:
    21  
    22  ```yaml
    23  # .goreleaser.yml
    24  env_files:
    25    # use only one or release will fail!
    26    github_token: ~/.path/to/my/gh_token
    27    gitlab_token: ~/.path/to/my/gl_token
    28    gitea_token: ~/.path/to/my/gitea_token
    29  ```
    30  
    31  !!! info
    32      you can define multiple env files, but the release process will fail
    33      because multiple tokens are defined. Use only one.
    34  
    35  ## GitHub Enterprise
    36  
    37  You can use GoReleaser with GitHub Enterprise by providing its URLs in
    38  the `.goreleaser.yml` configuration file:
    39  
    40  ```yaml
    41  # .goreleaser.yml
    42  github_urls:
    43    api: https://git.company.com/api/v3/
    44    upload: https://git.company.com/api/uploads/
    45    download: https://git.company.com/
    46    # set to true if you use a self-signed certificate
    47    skip_tls_verify: false
    48  ```
    49  
    50  If none are set, they default to GitHub's public URLs.
    51  
    52  ## GitLab Enterprise or private hosted
    53  
    54  You can use GoReleaser with GitLab Enterprise by providing its URLs in
    55  the `.goreleaser.yml` configuration file:
    56  
    57  ```yaml
    58  # .goreleaser.yml
    59  gitlab_urls:
    60    api: https://gitlab.mycompany.com/api/v4/
    61    download: https://gitlab.company.com
    62    # set to true if you use a self-signed certificate
    63    skip_tls_verify: false
    64  ```
    65  
    66  If none are set, they default to GitLab's public URLs.
    67  
    68  ## Gitea
    69  
    70  You can use GoReleaser with Gitea by providing its URLs in
    71  the `.goreleaser.yml` configuration file:
    72  
    73  ```yaml
    74  # .goreleaser.yml
    75  gitea_urls:
    76    api: https://gitea.myinstance.com/api/v1/
    77    download: https://gitea.myinstance.com
    78    # set to true if you use a self-signed certificate
    79    skip_tls_verify: false
    80  ```
    81  
    82  ## The dist folder
    83  
    84  By default, GoReleaser will create its artifacts in the `./dist` folder.
    85  If you must, you can change it by setting it in the `.goreleaser.yml` file:
    86  
    87  ```yaml
    88  # .goreleaser.yml
    89  dist: another-folder-that-is-not-dist
    90  ```
    91  
    92  ## Using the `main.version`
    93  
    94  Default wise GoReleaser sets three _ldflags_:
    95  
    96  - `main.version`: Current Git tag (the `v` prefix is stripped) or the name of
    97    the snapshot, if you're using the `--snapshot` flag
    98  - `main.commit`: Current git commit SHA
    99  - `main.date`: Date according [RFC3339](https://golang.org/pkg/time/#pkg-constants)
   100  
   101  You can use it in your `main.go` file:
   102  
   103  ```go
   104  package main
   105  
   106  import "fmt"
   107  
   108  var (
   109  	version = "dev"
   110  	commit  = "none"
   111  	date    = "unknown"
   112      builtBy = "unknown"
   113  )
   114  
   115  func main() {
   116    fmt.Printf("my app %s, commit %s, built at %s by %s", version, commit, date, builtBy)
   117  }
   118  ```
   119  
   120  You can override this by changing the `ldflags` option in the `build` section.
   121  
   122  ## Overriding Git Tags
   123  
   124  You can force the [build tag](/customization/build#define-build-tag)
   125  and [previous changelog tag](/customization/release#define-previous-tag)
   126  using environment variables. This is useful in cases where one git commit
   127  is referenced by multiple git tags.