Skip to content

Commit

Permalink
fix: improve chocolatey no archive error handling and docs
Browse files Browse the repository at this point in the history
closes #4450
  • Loading branch information
caarlos0 committed Nov 30, 2023
1 parent 6f598dc commit 142b94c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion internal/pipe/chocolatey/chocolatey.go
Expand Up @@ -17,6 +17,8 @@ import (
"github.com/goreleaser/goreleaser/pkg/context"
)

var errNoWindowsArchive = errors.New("chocolatey requires at least one windows archive")

// nuget package extension.
const nupkgFormat = "nupkg"

Expand Down Expand Up @@ -112,7 +114,7 @@ func doRun(ctx *context.Context, cl client.ReleaseURLTemplater, choco config.Cho
List()

if len(artifacts) == 0 {
return errors.New("chocolatey requires a windows build and archive")
return errNoWindowsArchive
}

// folderDir is the directory that then will be compressed to make the
Expand Down
2 changes: 1 addition & 1 deletion internal/pipe/chocolatey/chocolatey_test.go
Expand Up @@ -64,7 +64,7 @@ func Test_doRun(t *testing.T) {
IDs: []string{"no-app"},
Goamd64: "v1",
},
err: "chocolatey requires a windows build and archive",
err: errNoWindowsArchive.Error(),
},
{
name: "choco command not found",
Expand Down
10 changes: 6 additions & 4 deletions www/docs/customization/chocolatey.md
Expand Up @@ -14,8 +14,7 @@ Available options:
```yaml
# .goreleaser.yaml
chocolateys:
-
# Your app's package name.
- # Your app's package name.
# The value may not contain spaces or character that are not valid for a URL.
# If you want a good separator for words, use '-', not '.'.
#
Expand All @@ -24,6 +23,7 @@ chocolateys:

# IDs of the archives to use.
# Empty means all IDs.
# Attention: archives must not be in the 'binary' format.
ids:
- foo
- bar
Expand Down Expand Up @@ -53,7 +53,7 @@ chocolateys:
url_template: "https://github.com/foo/bar/releases/download/{{ .Tag }}/{{ .ArtifactName }}"

# App's icon.
icon_url: 'https://rawcdn.githack.com/foo/bar/efbdc760-395b-43f1-bf69-ba25c374d473/icon.png'
icon_url: "https://rawcdn.githack.com/foo/bar/efbdc760-395b-43f1-bf69-ba25c374d473/icon.png"

# Your app's copyright details.
copyright: 2022 Drummer Roll Inc
Expand Down Expand Up @@ -103,7 +103,7 @@ chocolateys:
# The api key that should be used to push to the chocolatey repository.
#
# WARNING: do not expose your api key in the configuration file!
api_key: '{{ .Env.CHOCOLATEY_API_KEY }}'
api_key: "{{ .Env.CHOCOLATEY_API_KEY }}"

# The source repository that will push the package to.
source_repo: "https://push.chocolatey.org/"
Expand All @@ -121,8 +121,10 @@ chocolateys:
```

!!! tip

Learn more about the [name template engine](/customization/templates/).

!!! note

GoReleaser will not install `chocolatey`/`choco` nor any of its dependencies
for you.

0 comments on commit 142b94c

Please sign in to comment.