1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-18 03:56:52 +02:00

feat(snapcraft): support title, icon, assumes & hooks (#3930)

This PR adds support for a few missing snapcraft fields which were
required for my project.
Reference here: https://snapcraft.io/docs/snapcraft-yaml-reference
This commit is contained in:
Adam Bouqdib 2023-06-12 13:03:24 +01:00 committed by GitHub
parent 215b96af55
commit d4bbf44d65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -37,16 +37,20 @@ var ErrNoSummary = errors.New("no summary provided for snapcraft")
// Metadata to generate the snap package. // Metadata to generate the snap package.
type Metadata struct { type Metadata struct {
Name string Name string
Title string
Version string Version string
Summary string Summary string
Description string Description string
Icon string
Base string `yaml:",omitempty"` Base string `yaml:",omitempty"`
License string `yaml:",omitempty"` License string `yaml:",omitempty"`
Grade string `yaml:",omitempty"` Grade string `yaml:",omitempty"`
Confinement string `yaml:",omitempty"` Confinement string `yaml:",omitempty"`
Architectures []string Architectures []string
Assumes []string `yaml:",omitempty"`
Layout map[string]LayoutMetadata `yaml:",omitempty"` Layout map[string]LayoutMetadata `yaml:",omitempty"`
Apps map[string]AppMetadata Apps map[string]AppMetadata
Hooks map[string]interface{} `yaml:",omitempty"`
Plugs map[string]interface{} `yaml:",omitempty"` Plugs map[string]interface{} `yaml:",omitempty"`
} }
@ -269,6 +273,14 @@ func create(ctx *context.Context, snap config.Snapcraft, arch string, binaries [
Apps: map[string]AppMetadata{}, Apps: map[string]AppMetadata{},
} }
if snap.Title != "" {
metadata.Title = snap.Title
}
if snap.Icon != "" {
metadata.Icon = snap.Icon
}
if snap.Base != "" { if snap.Base != "" {
metadata.Base = snap.Base metadata.Base = snap.Base
} }
@ -377,6 +389,8 @@ func create(ctx *context.Context, snap config.Snapcraft, arch string, binaries [
} }
metadata.Apps[name] = appMetadata metadata.Apps[name] = appMetadata
metadata.Assumes = snap.Assumes
metadata.Hooks = snap.Hooks
metadata.Plugs = snap.Plugs metadata.Plugs = snap.Plugs
} }

View File

@ -868,15 +868,19 @@ type Snapcraft struct {
ID string `yaml:"id,omitempty" json:"id,omitempty"` ID string `yaml:"id,omitempty" json:"id,omitempty"`
Builds []string `yaml:"builds,omitempty" json:"builds,omitempty"` Builds []string `yaml:"builds,omitempty" json:"builds,omitempty"`
Name string `yaml:"name,omitempty" json:"name,omitempty"` Name string `yaml:"name,omitempty" json:"name,omitempty"`
Title string `yaml:"title,omitempty" json:"title,omitempty"`
Summary string `yaml:"summary,omitempty" json:"summary,omitempty"` Summary string `yaml:"summary,omitempty" json:"summary,omitempty"`
Description string `yaml:"description,omitempty" json:"description,omitempty"` Description string `yaml:"description,omitempty" json:"description,omitempty"`
Icon string `yaml:"icon,omitempty" json:"icon,omitempty"`
Base string `yaml:"base,omitempty" json:"base,omitempty"` Base string `yaml:"base,omitempty" json:"base,omitempty"`
License string `yaml:"license,omitempty" json:"license,omitempty"` License string `yaml:"license,omitempty" json:"license,omitempty"`
Grade string `yaml:"grade,omitempty" json:"grade,omitempty"` Grade string `yaml:"grade,omitempty" json:"grade,omitempty"`
ChannelTemplates []string `yaml:"channel_templates,omitempty" json:"channel_templates,omitempty"` ChannelTemplates []string `yaml:"channel_templates,omitempty" json:"channel_templates,omitempty"`
Confinement string `yaml:"confinement,omitempty" json:"confinement,omitempty"` Confinement string `yaml:"confinement,omitempty" json:"confinement,omitempty"`
Assumes []string `yaml:"assumes,omitempty" json:"assumes,omitempty"`
Layout map[string]SnapcraftLayoutMetadata `yaml:"layout,omitempty" json:"layout,omitempty"` Layout map[string]SnapcraftLayoutMetadata `yaml:"layout,omitempty" json:"layout,omitempty"`
Apps map[string]SnapcraftAppMetadata `yaml:"apps,omitempty" json:"apps,omitempty"` Apps map[string]SnapcraftAppMetadata `yaml:"apps,omitempty" json:"apps,omitempty"`
Hooks map[string]interface{} `yaml:"hooks,omitempty" json:"hooks,omitempty"`
Plugs map[string]interface{} `yaml:"plugs,omitempty" json:"plugs,omitempty"` Plugs map[string]interface{} `yaml:"plugs,omitempty" json:"plugs,omitempty"`
Files []SnapcraftExtraFiles `yaml:"extra_files,omitempty" json:"extra_files,omitempty"` Files []SnapcraftExtraFiles `yaml:"extra_files,omitempty" json:"extra_files,omitempty"`