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

feat: add license to snapcraft (#1010)

This commit is contained in:
Grachev Mikhail 2019-04-17 23:26:30 +03:00 committed by Carlos Alexandro Becker
parent b8f5901265
commit 3da2b375c9
4 changed files with 13 additions and 0 deletions

View File

@ -35,6 +35,7 @@ type Metadata struct {
Version string
Summary string
Description string
License string `yaml:",omitempty"`
Grade string `yaml:",omitempty"`
Confinement string `yaml:",omitempty"`
Architectures []string
@ -146,6 +147,10 @@ func create(ctx *context.Context, arch string, binaries []artifact.Artifact) err
Apps: map[string]AppMetadata{},
}
if ctx.Config.Snapcraft.License != "" {
metadata.License = ctx.Config.Snapcraft.License
}
metadata.Name = ctx.Config.ProjectName
if ctx.Config.Snapcraft.Name != "" {
metadata.Name = ctx.Config.Snapcraft.Name

View File

@ -96,6 +96,7 @@ func TestRunPipeWithName(t *testing.T) {
Snapcraft: config.Snapcraft{
NameTemplate: "foo_{{.Arch}}",
Name: "testsnapname",
License: "MIT",
Summary: "test summary",
Description: "test description",
},
@ -110,6 +111,7 @@ func TestRunPipeWithName(t *testing.T) {
err = yaml.Unmarshal(yamlFile, &metadata)
assert.NoError(t, err)
assert.Equal(t, "testsnapname", metadata.Name)
assert.Equal(t, "MIT", metadata.License)
assert.Equal(t, "mybin", metadata.Apps["mybin"].Command)
assert.Equal(t, "mybin", metadata.Apps["testsnapname"].Command)
}
@ -140,6 +142,7 @@ func TestRunPipeWithBinaryInDir(t *testing.T) {
err = yaml.Unmarshal(yamlFile, &metadata)
assert.NoError(t, err)
assert.Equal(t, "testsnapname", metadata.Name)
assert.Equal(t, "", metadata.License)
assert.Equal(t, "mybin", metadata.Apps["mybin"].Command)
assert.Equal(t, "mybin", metadata.Apps["testsnapname"].Command)
}

View File

@ -227,6 +227,7 @@ type Snapcraft struct {
Name string `yaml:",omitempty"`
Summary string `yaml:",omitempty"`
Description string `yaml:",omitempty"`
License string `yaml:",omitempty"`
Grade string `yaml:",omitempty"`
Confinement string `yaml:",omitempty"`
Apps map[string]SnapcraftAppMetadata `yaml:",omitempty"`

View File

@ -69,6 +69,10 @@ snapcraft:
# are explained later. More info about confinement here:
# https://snapcraft.io/docs/reference/confinement
confinement: strict
# Your app's license, based on SPDX license expressions: https://spdx.org/licenses
# Default is empty.
license: MIT
# Each binary built by GoReleaser is an app inside the snap. In this section
# you can declare extra details for those binaries. It is optional.