From 142b94c533a21c4bfcfae405bc920b80cecb8b41 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Wed, 29 Nov 2023 23:27:05 -0300 Subject: [PATCH] fix: improve chocolatey no archive error handling and docs closes #4450 --- internal/pipe/chocolatey/chocolatey.go | 4 +++- internal/pipe/chocolatey/chocolatey_test.go | 2 +- www/docs/customization/chocolatey.md | 10 ++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/pipe/chocolatey/chocolatey.go b/internal/pipe/chocolatey/chocolatey.go index 115eb40bf94..fada009260d 100644 --- a/internal/pipe/chocolatey/chocolatey.go +++ b/internal/pipe/chocolatey/chocolatey.go @@ -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" @@ -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 diff --git a/internal/pipe/chocolatey/chocolatey_test.go b/internal/pipe/chocolatey/chocolatey_test.go index f80821e4b18..461d8eb90c7 100644 --- a/internal/pipe/chocolatey/chocolatey_test.go +++ b/internal/pipe/chocolatey/chocolatey_test.go @@ -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", diff --git a/www/docs/customization/chocolatey.md b/www/docs/customization/chocolatey.md index 144055d4754..d5f92196841 100644 --- a/www/docs/customization/chocolatey.md +++ b/www/docs/customization/chocolatey.md @@ -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 '.'. # @@ -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 @@ -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 @@ -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/" @@ -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.