mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-03 13:11:48 +02:00
feat(snapcraft): allow to disable (#4228)
allows to disable a snapcraft configuration based on a template, e.g. if snapshot, nightly, etc
This commit is contained in:
parent
89b76df4bb
commit
d0a86edd90
@ -317,6 +317,7 @@ snapcrafts:
|
||||
grade: stable
|
||||
confinement: classic
|
||||
publish: true
|
||||
disable: "{{ if .IsNightly }}true{{ end }}"
|
||||
|
||||
sboms:
|
||||
- artifacts: archive
|
||||
|
@ -157,9 +157,13 @@ func doRun(ctx *context.Context, snap config.Snapcraft) error {
|
||||
if err := tpl.ApplyAll(
|
||||
&snap.Summary,
|
||||
&snap.Description,
|
||||
&snap.Disable,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
if snap.Disable == "true" {
|
||||
return pipe.Skip("configuration is disabled")
|
||||
}
|
||||
if snap.Summary == "" && snap.Description == "" {
|
||||
return pipe.Skip("no summary nor description were provided")
|
||||
}
|
||||
|
@ -79,11 +79,20 @@ func TestRunPipe(t *testing.T) {
|
||||
Builds: []string{"bar"},
|
||||
ChannelTemplates: []string{"stable"},
|
||||
},
|
||||
{
|
||||
NameTemplate: "bar_{{.Arch}}",
|
||||
Summary: "test summary",
|
||||
Description: "test description",
|
||||
Publish: true,
|
||||
Builds: []string{"bar"},
|
||||
ChannelTemplates: []string{"stable"},
|
||||
Disable: "{{.Env.SKIP}}",
|
||||
},
|
||||
},
|
||||
}, testctx.WithCurrentTag("v1.2.3"), testctx.WithVersion("1.2.3"))
|
||||
}, testctx.WithCurrentTag("v1.2.3"), testctx.WithVersion("1.2.3"), testctx.WithEnv(map[string]string{"SKIP": "true"}))
|
||||
addBinaries(t, ctx, "foo", filepath.Join(dist, "foo"))
|
||||
addBinaries(t, ctx, "bar", filepath.Join(dist, "bar"))
|
||||
require.NoError(t, Pipe{}.Run(ctx))
|
||||
testlib.AssertSkipped(t, Pipe{}.Run(ctx))
|
||||
list := ctx.Artifacts.Filter(artifact.ByType(artifact.PublishableSnapcraft)).List()
|
||||
require.Len(t, list, 9)
|
||||
}
|
||||
|
@ -978,6 +978,7 @@ type Snapcraft struct {
|
||||
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"`
|
||||
Disable string `yaml:"disable,omitempty" json:"disable,omitempty" jsonschema:"oneof_type=string;boolean"`
|
||||
|
||||
Files []SnapcraftExtraFiles `yaml:"extra_files,omitempty" json:"extra_files,omitempty"`
|
||||
}
|
||||
|
@ -62,6 +62,11 @@ snapcrafts:
|
||||
# store.
|
||||
description: This is the best drum roll application out there. Install it and awe!
|
||||
|
||||
# Disable this configuration.
|
||||
#
|
||||
# Templates: allowed (since v1.20)
|
||||
disable: true
|
||||
|
||||
# Channels in store where snap will be pushed.
|
||||
#
|
||||
# More info about channels here:
|
||||
|
Loading…
x
Reference in New Issue
Block a user