mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-04-15 11:56:56 +02:00
feat: add license to snapcraft (#1010)
This commit is contained in:
parent
b8f5901265
commit
3da2b375c9
@ -35,6 +35,7 @@ type Metadata struct {
|
|||||||
Version string
|
Version string
|
||||||
Summary string
|
Summary string
|
||||||
Description string
|
Description string
|
||||||
|
License string `yaml:",omitempty"`
|
||||||
Grade string `yaml:",omitempty"`
|
Grade string `yaml:",omitempty"`
|
||||||
Confinement string `yaml:",omitempty"`
|
Confinement string `yaml:",omitempty"`
|
||||||
Architectures []string
|
Architectures []string
|
||||||
@ -146,6 +147,10 @@ func create(ctx *context.Context, arch string, binaries []artifact.Artifact) err
|
|||||||
Apps: map[string]AppMetadata{},
|
Apps: map[string]AppMetadata{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.Config.Snapcraft.License != "" {
|
||||||
|
metadata.License = ctx.Config.Snapcraft.License
|
||||||
|
}
|
||||||
|
|
||||||
metadata.Name = ctx.Config.ProjectName
|
metadata.Name = ctx.Config.ProjectName
|
||||||
if ctx.Config.Snapcraft.Name != "" {
|
if ctx.Config.Snapcraft.Name != "" {
|
||||||
metadata.Name = ctx.Config.Snapcraft.Name
|
metadata.Name = ctx.Config.Snapcraft.Name
|
||||||
|
@ -96,6 +96,7 @@ func TestRunPipeWithName(t *testing.T) {
|
|||||||
Snapcraft: config.Snapcraft{
|
Snapcraft: config.Snapcraft{
|
||||||
NameTemplate: "foo_{{.Arch}}",
|
NameTemplate: "foo_{{.Arch}}",
|
||||||
Name: "testsnapname",
|
Name: "testsnapname",
|
||||||
|
License: "MIT",
|
||||||
Summary: "test summary",
|
Summary: "test summary",
|
||||||
Description: "test description",
|
Description: "test description",
|
||||||
},
|
},
|
||||||
@ -110,6 +111,7 @@ func TestRunPipeWithName(t *testing.T) {
|
|||||||
err = yaml.Unmarshal(yamlFile, &metadata)
|
err = yaml.Unmarshal(yamlFile, &metadata)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, "testsnapname", metadata.Name)
|
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["mybin"].Command)
|
||||||
assert.Equal(t, "mybin", metadata.Apps["testsnapname"].Command)
|
assert.Equal(t, "mybin", metadata.Apps["testsnapname"].Command)
|
||||||
}
|
}
|
||||||
@ -140,6 +142,7 @@ func TestRunPipeWithBinaryInDir(t *testing.T) {
|
|||||||
err = yaml.Unmarshal(yamlFile, &metadata)
|
err = yaml.Unmarshal(yamlFile, &metadata)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, "testsnapname", metadata.Name)
|
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["mybin"].Command)
|
||||||
assert.Equal(t, "mybin", metadata.Apps["testsnapname"].Command)
|
assert.Equal(t, "mybin", metadata.Apps["testsnapname"].Command)
|
||||||
}
|
}
|
||||||
|
@ -227,6 +227,7 @@ type Snapcraft struct {
|
|||||||
Name string `yaml:",omitempty"`
|
Name string `yaml:",omitempty"`
|
||||||
Summary string `yaml:",omitempty"`
|
Summary string `yaml:",omitempty"`
|
||||||
Description string `yaml:",omitempty"`
|
Description string `yaml:",omitempty"`
|
||||||
|
License string `yaml:",omitempty"`
|
||||||
Grade string `yaml:",omitempty"`
|
Grade string `yaml:",omitempty"`
|
||||||
Confinement string `yaml:",omitempty"`
|
Confinement string `yaml:",omitempty"`
|
||||||
Apps map[string]SnapcraftAppMetadata `yaml:",omitempty"`
|
Apps map[string]SnapcraftAppMetadata `yaml:",omitempty"`
|
||||||
|
@ -70,6 +70,10 @@ snapcraft:
|
|||||||
# https://snapcraft.io/docs/reference/confinement
|
# https://snapcraft.io/docs/reference/confinement
|
||||||
confinement: strict
|
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
|
# 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.
|
# you can declare extra details for those binaries. It is optional.
|
||||||
apps:
|
apps:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user