1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
goreleaser/www/docs/errors/multiple-tokens.md
Carlos Alexandro Becker dc6a4e7e2f
feat: allow to forcefully use a token when multiple are set (#3910)
This would allow to, when multiple tokens are set in the environment,
force which one you want to use.

The need for this comes from the fact gitea sets both `GITHUB_TOKEN` and
`GITEA_TOKEN`, and doesn't allow to easily disable either.

With this, users can add a `GORELEASER_FORCE_TOKEN=gitea` to force the
gitea client to be used.

I'm not sure what's the best name for this env yet, happy to hear
suggestions.

Also improved the `env_test.go` file a bit, as it was kinda messy with
env vars...

refs https://github.com/orgs/goreleaser/discussions/3900

---------

Signed-off-by: Carlos A Becker <caarlos0@users.noreply.github.com>
2023-04-05 16:33:22 -03:00

1.5 KiB

Multiple tokens found, but only one is allowed

GoReleaser infers if you are using GitHub, GitLab or Gitea by which tokens are provided. If you have multiple tokens set, you'll get this error.

Here's an example:

   ⨯ release failed after 0.02s error=gmultiple tokens found, but only one is allowed: GITHUB_TOKEN, GITLAB_TOKEN

Learn more at https://goreleaser.com/errors/multiple-tokens

In this case, you either unset GITHUB_TOKEN or GITLAB_TOKEN. You can read more about it in the SCM docs.

This can also happen if you load the tokens from files. The default paths are:

  • ~/.config/goreleaser/github_token
  • ~/.config/goreleaser/gitlab_token
  • ~/.config/goreleaser/gitea_token

If you have more than one of these files, but for a particular project, you want to force one of them, you can explicitly disable the others by setting them to a file you know won't exist:

# .goreleaser.yaml
env_files:
  gitlab_token: ~/nope
  gitea_token: ~/nope

Forcing a specific token

This will prevent using both GitLab and Gitea tokens.

If GoReleaser is being run with more than one of the *_TOKEN environment variables and you can't unset any of them, you can force GoReleaser to use a specific one by exporting a GORELEASER_FORCE_TOKEN environment variable.

So, for instance, if you have both GITHUB_TOKEN and GITEA_TOKEN set and want GoReleaser to pick GITEA_TOKEN, you can set GORELEASER_FORCE_TOKEN=gitea. GoReleaser will then unset GITHUB_TOKEN and proceed.