1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-04 03:11:55 +02:00

fix(winget): add missing fields, more templates (#4164)

This adds missing fields:

- LicenseURL
- CopyrightURL
- Tags

As well as make several more fields templateable.


cc/ @twpayne

Co-authored-by: Tom Payne <tom.payne@flarm.com>
This commit is contained in:
Carlos Alexandro Becker 2023-07-05 23:33:18 -03:00 committed by GitHub
parent 4c9314b06f
commit a324009978
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 166 additions and 50 deletions

View File

@ -95,25 +95,27 @@ type Installer struct {
// nolint: tagliatelle
type Locale struct {
PackageIdentifier string `yaml:"PackageIdentifier,omitempty"`
PackageVersion string `yaml:"PackageVersion,omitempty"`
PackageLocale string `yaml:"PackageLocale,omitempty"`
Publisher string `yaml:"Publisher,omitempty"`
PublisherURL string `yaml:"PublisherUrl,omitempty"`
Author string `yaml:"Author,omitempty"`
PackageName string `yaml:"PackageName,omitempty"`
PackageURL string `yaml:"PackageUrl,omitempty"`
License string `yaml:"License,omitempty"`
LicenseURL string `yaml:"LicenseUrl,omitempty"`
Copyright string `yaml:"Copyright,omitempty"`
ShortDescription string `yaml:"ShortDescription,omitempty"`
Description string `yaml:"Description,omitempty"`
Moniker string `yaml:"Moniker,omitempty"`
Tags []string `yaml:"Tags,omitempty"`
ReleaseNotes string `yaml:"ReleaseNotes,omitempty"`
ReleaseNotesURL string `yaml:"ReleaseNotesUrl,omitempty"`
ManifestType string `yaml:"ManifestType,omitempty"`
ManifestVersion string `yaml:"ManifestVersion,omitempty"`
PackageIdentifier string `yaml:"PackageIdentifier,omitempty"`
PackageVersion string `yaml:"PackageVersion,omitempty"`
PackageLocale string `yaml:"PackageLocale,omitempty"`
Publisher string `yaml:"Publisher,omitempty"`
PublisherURL string `yaml:"PublisherUrl,omitempty"`
PublisherSupportURL string `yaml:"PublisherSupportUrl,omitempty"`
Author string `yaml:"Author,omitempty"`
PackageName string `yaml:"PackageName,omitempty"`
PackageURL string `yaml:"PackageUrl,omitempty"`
License string `yaml:"License,omitempty"`
LicenseURL string `yaml:"LicenseUrl,omitempty"`
Copyright string `yaml:"Copyright,omitempty"`
CopyrightURL string `yaml:"CopyrightUrl,omitempty"`
ShortDescription string `yaml:"ShortDescription,omitempty"`
Description string `yaml:"Description,omitempty"`
Moniker string `yaml:"Moniker,omitempty"`
Tags []string `yaml:"Tags,omitempty"`
ReleaseNotes string `yaml:"ReleaseNotes,omitempty"`
ReleaseNotesURL string `yaml:"ReleaseNotesUrl,omitempty"`
ManifestType string `yaml:"ManifestType,omitempty"`
ManifestVersion string `yaml:"ManifestVersion,omitempty"`
}
var fromGoArch = map[string]string{

View File

@ -5,12 +5,14 @@ PackageVersion: 1.2.1
PackageLocale: en-US
Publisher: Beckersoft
PublisherUrl: https://carlosbecker.com
PublisherSupportUrl: https://carlosbecker.com/support
Author: Carlos Becker
PackageName: foo
PackageUrl: https://goreleaser.com
License: MIT
LicenseUrl: https://goreleaser.com/eula/
Copyright: bla bla bla
CopyrightUrl: https://goreleaser.com/copyright
ShortDescription: foo
Description: |-
long foo bar
@ -19,6 +21,9 @@ Description: |-
sss
Moniker: foo
Tags:
- foo
- bar
ReleaseNotes: the changelog for this release...
ReleaseNotesUrl: https://github.com/goreleaser/goreleaser/tags/v1.2.1
ManifestType: defaultLocale

View File

@ -109,12 +109,17 @@ func (p Pipe) doRun(ctx *context.Context, winget config.Winget, cl client.Releas
&winget.Name,
&winget.Author,
&winget.PublisherURL,
&winget.PublisherSupportURL,
&winget.Homepage,
&winget.SkipUpload,
&winget.Description,
&winget.ShortDescription,
&winget.ReleaseNotesURL,
&winget.Path,
&winget.Copyright,
&winget.CopyrightURL,
&winget.License,
&winget.LicenseURL,
)
if err != nil {
return err
@ -251,25 +256,27 @@ func (p Pipe) doRun(ctx *context.Context, winget config.Winget, cl client.Releas
}
return createYAML(ctx, winget, Locale{
PackageIdentifier: winget.PackageIdentifier,
PackageVersion: ctx.Version,
PackageLocale: defaultLocale,
Publisher: winget.Publisher,
PublisherURL: winget.PublisherURL,
Author: winget.Author,
PackageName: winget.Name,
PackageURL: winget.Homepage,
License: winget.License,
LicenseURL: winget.LicenseURL,
Copyright: winget.Copyright,
ShortDescription: winget.ShortDescription,
Description: winget.Description,
Moniker: winget.Name,
Tags: []string{},
ReleaseNotes: winget.ReleaseNotes,
ReleaseNotesURL: winget.ReleaseNotesURL,
ManifestType: "defaultLocale",
ManifestVersion: manifestVersion,
PackageIdentifier: winget.PackageIdentifier,
PackageVersion: ctx.Version,
PackageLocale: defaultLocale,
Publisher: winget.Publisher,
PublisherURL: winget.PublisherURL,
PublisherSupportURL: winget.PublisherSupportURL,
Author: winget.Author,
PackageName: winget.Name,
PackageURL: winget.Homepage,
License: winget.License,
LicenseURL: winget.LicenseURL,
Copyright: winget.Copyright,
CopyrightURL: winget.CopyrightURL,
ShortDescription: winget.ShortDescription,
Description: winget.Description,
Moniker: winget.Name,
Tags: winget.Tags,
ReleaseNotes: winget.ReleaseNotes,
ReleaseNotesURL: winget.ReleaseNotesURL,
ManifestType: "defaultLocale",
ManifestVersion: manifestVersion,
}, artifact.WingetDefaultLocale)
}

View File

@ -62,18 +62,20 @@ func TestRunPipe(t *testing.T) {
name: "full",
expectPath: "manifests/b/Beckersoft LTDA/foo/1.2.1",
winget: config.Winget{
Name: "foo",
Publisher: "Beckersoft",
PublisherURL: "https://carlosbecker.com",
Copyright: "bla bla bla",
Author: "Carlos Becker",
Path: "manifests/b/Beckersoft LTDA/foo/{{.Version}}",
Repository: config.RepoRef{Owner: "foo", Name: "bar"},
CommitAuthor: config.CommitAuthor{},
IDs: []string{"foo"},
Goamd64: "v1",
SkipUpload: "false",
ShortDescription: "foo",
Name: "foo",
Publisher: "Beckersoft",
PublisherURL: "https://carlosbecker.com",
PublisherSupportURL: "https://carlosbecker.com/support",
Copyright: "bla bla bla",
CopyrightURL: "https://goreleaser.com/copyright",
Author: "Carlos Becker",
Path: "manifests/b/Beckersoft LTDA/foo/{{.Version}}",
Repository: config.RepoRef{Owner: "foo", Name: "bar"},
CommitAuthor: config.CommitAuthor{},
IDs: []string{"foo"},
Goamd64: "v1",
SkipUpload: "false",
ShortDescription: "foo",
Description: `long foo bar
yadaa yada yada loooaaasssss
@ -84,6 +86,7 @@ func TestRunPipe(t *testing.T) {
LicenseURL: "https://goreleaser.com/eula/",
ReleaseNotesURL: "https://github.com/goreleaser/goreleaser/tags/{{.Tag}}",
ReleaseNotes: "{{.Changelog}}",
Tags: []string{"foo", "bar"},
},
},
{
@ -446,6 +449,80 @@ func TestRunPipe(t *testing.T) {
},
},
},
{
name: "bad-publisher-support-url-tmpl",
expectRunErrorIs: &template.Error{},
winget: config.Winget{
Name: "foo",
Publisher: "Beckersoft",
PublisherSupportURL: "{{.Nope}}",
License: "MIT",
ShortDescription: "foo bar zaz",
Repository: config.RepoRef{
Owner: "foo",
Name: "bar",
},
},
},
{
name: "bad-copyright-tmpl",
expectRunErrorIs: &template.Error{},
winget: config.Winget{
Name: "foo",
Publisher: "Beckersoft",
License: "MIT",
Copyright: "{{ .Nope }}",
ShortDescription: "foo bar zaz",
Repository: config.RepoRef{
Owner: "foo",
Name: "bar",
},
},
},
{
name: "bad-copyright-url-tmpl",
expectRunErrorIs: &template.Error{},
winget: config.Winget{
Name: "{{ .Nope }}",
Publisher: "Beckersoft",
License: "MIT",
CopyrightURL: "{{ .Nope }}",
ShortDescription: "foo bar zaz",
Repository: config.RepoRef{
Owner: "foo",
Name: "bar",
},
},
},
{
name: "bad-license-tmpl",
expectRunErrorIs: &template.Error{},
winget: config.Winget{
Name: "foo",
Publisher: "Beckersoft",
License: "{{ .Nope }}",
ShortDescription: "foo bar zaz",
Repository: config.RepoRef{
Owner: "foo",
Name: "bar",
},
},
},
{
name: "bad-license-url-tmpl",
expectRunErrorIs: &template.Error{},
winget: config.Winget{
Name: "foo",
Publisher: "Beckersoft",
License: "MIT",
LicenseURL: "{{ .Nope }}",
ShortDescription: "foo bar zaz",
Repository: config.RepoRef{
Owner: "foo",
Name: "bar",
},
},
},
{
name: "skip-upload",
expectPublishErrorIs: errSkipUpload,

View File

@ -266,7 +266,9 @@ type Winget struct {
PackageIdentifier string `yaml:"package_identifier,omitempty" json:"package_identifier,omitempty"`
Publisher string `yaml:"publisher,omitempty" json:"publisher,omitempty"`
PublisherURL string `yaml:"publisher_url,omitempty" json:"publisher_url,omitempty"`
PublisherSupportURL string `yaml:"publisher_support_url,omitempty" json:"publisher_support_url,omitempty"`
Copyright string `yaml:"copyright,omitempty" json:"copyright,omitempty"`
CopyrightURL string `yaml:"copyright_url,omitempty" json:"copyright_url,omitempty"`
Author string `yaml:"author,omitempty" json:"author,omitempty"`
Path string `yaml:"path,omitempty" json:"path,omitempty"`
Repository RepoRef `yaml:"repository,omitempty" json:"repository,omitempty"`
@ -283,6 +285,7 @@ type Winget struct {
LicenseURL string `yaml:"license_url,omitempty" json:"license_url,omitempty"`
ReleaseNotes string `yaml:"release_notes,omitempty" json:"release_notes,omitempty"`
ReleaseNotesURL string `yaml:"release_notes_url,omitempty" json:"release_notes_url,omitempty"`
Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"`
}
// Krew contains the krew section.

View File

@ -30,6 +30,8 @@ winget:
short_description: "Software to create fast and easy drum rolls."
# License name.
#
# Templates: allowed
# Required.
license: "mit"
@ -38,6 +40,11 @@ winget:
# Templates: allowed
publisher_url: https://goreleaser.com
# Publisher support URL.
#
# Templates: allowed
publisher_support_url: "https://github.com/user/repo/issues/new"
# Package identifier.
#
# Default: Publisher.ProjectName
@ -86,11 +93,20 @@ winget:
description: "Software to create fast and easy drum rolls."
# License URL.
#
# Templates: allowed
license_url: "https://goreleaser.com/license"
# Copyright.
#
# Templates: allowed
copyright: "Becker Software LTDA"
# Copyright URL.
#
# Templates: allowed
copyright_url: "https://goreleaser.com/copyright"
# Setting this will prevent goreleaser to actually try to commit the updated
# package - instead, it will be stored on the dist folder only,
# leaving the responsibility of publishing it to the user.
@ -114,6 +130,12 @@ winget:
# Templates: allowed
release_notes_url: "https://foo.bar/changelog/{{.Version}}"
# Tags.
tags:
- golang
- cli
{% include-markdown "../includes/repository.md" comments=false %}
```