1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2024-12-31 01:53:50 +02:00

feat: add force_token to config (#3936)

As a follow-up to #3910, this adds `force_token` to the config.

Signed-off-by: jolheiser <john.olheiser@gmail.com>
This commit is contained in:
John Olheiser 2023-04-23 11:53:45 -05:00 committed by GitHub
parent 44c6f733eb
commit 6b86499655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 3 deletions

View File

@ -69,7 +69,11 @@ func (Pipe) Run(ctx *context.Context) error {
gitlabToken, gitlabTokenErr := loadEnv("GITLAB_TOKEN", ctx.Config.EnvFiles.GitLabToken)
giteaToken, giteaTokenErr := loadEnv("GITEA_TOKEN", ctx.Config.EnvFiles.GiteaToken)
switch os.Getenv("GORELEASER_FORCE_TOKEN") {
forceToken := ctx.Config.ForceToken
if forceToken == "" {
forceToken = os.Getenv("GORELEASER_FORCE_TOKEN")
}
switch strings.ToLower(forceToken) {
case "github":
gitlabToken = ""
giteaToken = ""

View File

@ -981,6 +981,9 @@ type Project struct {
// this is a hack ¯\_(ツ)_/¯
SingleBuild Build `yaml:"build,omitempty" json:"build,omitempty" jsonschema_description:"deprecated: use builds instead"` // deprecated
// force the SCM token to use when multiple are set
ForceToken string `yaml:"force_token,omitempty" json:"force_token,omitempty" jsonschema:"enum=github,enum=gitlab,enum=gitea,enum=,default="`
// should be set if using github enterprise
GitHubURLs GitHubURLs `yaml:"github_urls,omitempty" json:"github_urls,omitempty"`

View File

@ -32,12 +32,12 @@ env_files:
gitea_token: ~/nope
```
This will prevent using both GitLab and Gitea tokens.
## Forcing a specific token
> Since: v1.17
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.
@ -46,3 +46,10 @@ 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.
You can also force a token by using `force_token` in your config:
```yaml
# .goreleaser.yaml
force_token: gitea
```

10
www/docs/static/schema.json generated vendored
View File

@ -2141,6 +2141,16 @@
"$ref": "#/$defs/Build",
"description": "deprecated: use builds instead"
},
"force_token": {
"type": "string",
"enum": [
"github",
"gitlab",
"gitea",
""
],
"default": ""
},
"github_urls": {
"$ref": "#/$defs/GitHubURLs"
},