mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-04-13 11:50:34 +02:00
feat: scoop formula path
closes #2310 Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
parent
a0dd45592e
commit
c5bcff2b00
@ -7,6 +7,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -97,7 +98,7 @@ func doRun(ctx *context.Context, cl client.Client) error {
|
|||||||
return ErrNoWindows
|
return ErrNoWindows
|
||||||
}
|
}
|
||||||
|
|
||||||
path := scoop.Name + ".json"
|
filename := scoop.Name + ".json"
|
||||||
|
|
||||||
data, err := dataFor(ctx, cl, archives)
|
data, err := dataFor(ctx, cl, archives)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -108,9 +109,9 @@ func doRun(ctx *context.Context, cl client.Client) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
filename := filepath.Join(ctx.Config.Dist, path)
|
distPath := filepath.Join(ctx.Config.Dist, filename)
|
||||||
log.WithField("manifest", filename).Info("writing")
|
log.WithField("manifest", distPath).Info("writing")
|
||||||
if err := os.WriteFile(filename, content.Bytes(), 0o644); err != nil {
|
if err := os.WriteFile(distPath, content.Bytes(), 0o644); err != nil {
|
||||||
return fmt.Errorf("failed to write scoop manifest: %w", err)
|
return fmt.Errorf("failed to write scoop manifest: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +143,7 @@ func doRun(ctx *context.Context, cl client.Client) error {
|
|||||||
scoop.CommitAuthor,
|
scoop.CommitAuthor,
|
||||||
repo,
|
repo,
|
||||||
content.Bytes(),
|
content.Bytes(),
|
||||||
path,
|
path.Join(scoop.Folder, filename),
|
||||||
commitMessage,
|
commitMessage,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,12 @@ func Test_doRun(t *testing.T) {
|
|||||||
file := filepath.Join(folder, "archive")
|
file := filepath.Join(folder, "archive")
|
||||||
require.NoError(t, os.WriteFile(file, []byte("lorem ipsum"), 0o644))
|
require.NoError(t, os.WriteFile(file, []byte("lorem ipsum"), 0o644))
|
||||||
|
|
||||||
|
type args struct {
|
||||||
|
ctx *context.Context
|
||||||
|
client *DummyClient
|
||||||
|
}
|
||||||
|
|
||||||
|
type asserter func(*testing.T, args)
|
||||||
type errChecker func(*testing.T, error)
|
type errChecker func(*testing.T, error)
|
||||||
shouldErr := func(msg string) errChecker {
|
shouldErr := func(msg string) errChecker {
|
||||||
return func(t *testing.T, err error) {
|
return func(t *testing.T, err error) {
|
||||||
@ -69,19 +75,20 @@ func Test_doRun(t *testing.T) {
|
|||||||
require.EqualError(t, err, msg)
|
require.EqualError(t, err, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
noAssertions := func(t *testing.T, _ args) {
|
||||||
|
t.Helper()
|
||||||
|
}
|
||||||
shouldNotErr := func(t *testing.T, err error) {
|
shouldNotErr := func(t *testing.T, err error) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
type args struct {
|
|
||||||
ctx *context.Context
|
|
||||||
client client.Client
|
|
||||||
}
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
args args
|
args args
|
||||||
artifacts []*artifact.Artifact
|
artifacts []*artifact.Artifact
|
||||||
assertError errChecker
|
assertError errChecker
|
||||||
|
assert asserter
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"valid public github",
|
"valid public github",
|
||||||
@ -113,6 +120,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
Owner: "test",
|
Owner: "test",
|
||||||
Name: "test",
|
Name: "test",
|
||||||
},
|
},
|
||||||
|
Folder: "scoops",
|
||||||
Description: "A run pipe test formula",
|
Description: "A run pipe test formula",
|
||||||
Homepage: "https://github.com/goreleaser",
|
Homepage: "https://github.com/goreleaser",
|
||||||
},
|
},
|
||||||
@ -125,6 +133,10 @@ func Test_doRun(t *testing.T) {
|
|||||||
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
||||||
},
|
},
|
||||||
shouldNotErr,
|
shouldNotErr,
|
||||||
|
func(t *testing.T, a args) {
|
||||||
|
t.Helper()
|
||||||
|
require.Equal(t, "scoops/run-pipe.json", a.client.Path)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"wrap in directory",
|
"wrap in directory",
|
||||||
@ -184,6 +196,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
shouldNotErr,
|
shouldNotErr,
|
||||||
|
noAssertions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid enterprise github",
|
"valid enterprise github",
|
||||||
@ -228,6 +241,10 @@ func Test_doRun(t *testing.T) {
|
|||||||
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
||||||
},
|
},
|
||||||
shouldNotErr,
|
shouldNotErr,
|
||||||
|
func(t *testing.T, a args) {
|
||||||
|
t.Helper()
|
||||||
|
require.Equal(t, "run-pipe.json", a.client.Path)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid public gitlab",
|
"valid public gitlab",
|
||||||
@ -281,6 +298,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
shouldNotErr,
|
shouldNotErr,
|
||||||
|
noAssertions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"valid enterprise gitlab",
|
"valid enterprise gitlab",
|
||||||
@ -335,6 +353,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
shouldNotErr,
|
shouldNotErr,
|
||||||
|
noAssertions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"token type not implemented for pipe",
|
"token type not implemented for pipe",
|
||||||
@ -377,6 +396,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
||||||
},
|
},
|
||||||
shouldErr(ErrTokenTypeNotImplementedForScoop.Error()),
|
shouldErr(ErrTokenTypeNotImplementedForScoop.Error()),
|
||||||
|
noAssertions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"no windows build",
|
"no windows build",
|
||||||
@ -420,6 +440,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
{Name: "foo_1.0.1_linux_386.tar.gz", Goos: "linux", Goarch: "386"},
|
{Name: "foo_1.0.1_linux_386.tar.gz", Goos: "linux", Goarch: "386"},
|
||||||
},
|
},
|
||||||
shouldErr("scoop requires a windows build"),
|
shouldErr("scoop requires a windows build"),
|
||||||
|
noAssertions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"no scoop",
|
"no scoop",
|
||||||
@ -455,6 +476,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386"},
|
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386"},
|
||||||
},
|
},
|
||||||
shouldErr(pipe.ErrSkipDisabledPipe.Error()),
|
shouldErr(pipe.ErrSkipDisabledPipe.Error()),
|
||||||
|
noAssertions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"no publish",
|
"no publish",
|
||||||
@ -499,6 +521,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
||||||
},
|
},
|
||||||
shouldErr(pipe.ErrSkipPublishEnabled.Error()),
|
shouldErr(pipe.ErrSkipPublishEnabled.Error()),
|
||||||
|
noAssertions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"is draft",
|
"is draft",
|
||||||
@ -539,6 +562,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
||||||
},
|
},
|
||||||
shouldErr("release is marked as draft"),
|
shouldErr("release is marked as draft"),
|
||||||
|
noAssertions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"is prerelease and skip upload set to auto",
|
"is prerelease and skip upload set to auto",
|
||||||
@ -589,6 +613,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
{Name: "foo_1.0.1-pre.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
{Name: "foo_1.0.1-pre.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
||||||
},
|
},
|
||||||
shouldErr("release is prerelease"),
|
shouldErr("release is prerelease"),
|
||||||
|
noAssertions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"skip upload set to true",
|
"skip upload set to true",
|
||||||
@ -633,6 +658,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
{Name: "foo_1.0.1-pre.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
{Name: "foo_1.0.1-pre.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
||||||
},
|
},
|
||||||
shouldErr("scoop.skip_upload is true"),
|
shouldErr("scoop.skip_upload is true"),
|
||||||
|
noAssertions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"release is disabled",
|
"release is disabled",
|
||||||
@ -673,6 +699,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
||||||
},
|
},
|
||||||
shouldErr("release is disabled"),
|
shouldErr("release is disabled"),
|
||||||
|
noAssertions,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"no archive",
|
"no archive",
|
||||||
@ -713,6 +740,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
{Name: "foo_1.0.1_windows_386.tar.gz", Goos: "windows", Goarch: "386", Path: file},
|
||||||
},
|
},
|
||||||
shouldErr("archive format is binary"),
|
shouldErr("archive format is binary"),
|
||||||
|
noAssertions,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
@ -724,6 +752,7 @@ func Test_doRun(t *testing.T) {
|
|||||||
require.NoError(t, Pipe{}.Default(ctx))
|
require.NoError(t, Pipe{}.Default(ctx))
|
||||||
|
|
||||||
tt.assertError(t, doRun(ctx, tt.args.client))
|
tt.assertError(t, doRun(ctx, tt.args.client))
|
||||||
|
tt.assert(t, tt.args)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1096,6 +1125,7 @@ func TestWrapInDirectory(t *testing.T) {
|
|||||||
type DummyClient struct {
|
type DummyClient struct {
|
||||||
CreatedFile bool
|
CreatedFile bool
|
||||||
Content string
|
Content string
|
||||||
|
Path string
|
||||||
NotImplemented bool
|
NotImplemented bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1117,6 +1147,7 @@ func (dc *DummyClient) ReleaseURLTemplate(ctx *context.Context) (string, error)
|
|||||||
func (dc *DummyClient) CreateFile(ctx *context.Context, commitAuthor config.CommitAuthor, repo client.Repo, content []byte, path, msg string) (err error) {
|
func (dc *DummyClient) CreateFile(ctx *context.Context, commitAuthor config.CommitAuthor, repo client.Repo, content []byte, path, msg string) (err error) {
|
||||||
dc.CreatedFile = true
|
dc.CreatedFile = true
|
||||||
dc.Content = string(content)
|
dc.Content = string(content)
|
||||||
|
dc.Path = path
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +116,7 @@ type Homebrew struct {
|
|||||||
type Scoop struct {
|
type Scoop struct {
|
||||||
Name string `yaml:",omitempty"`
|
Name string `yaml:",omitempty"`
|
||||||
Bucket RepoRef `yaml:",omitempty"`
|
Bucket RepoRef `yaml:",omitempty"`
|
||||||
|
Folder string `yaml:",omitempty"`
|
||||||
CommitAuthor CommitAuthor `yaml:"commit_author,omitempty"`
|
CommitAuthor CommitAuthor `yaml:"commit_author,omitempty"`
|
||||||
CommitMessageTemplate string `yaml:"commit_msg_template,omitempty"`
|
CommitMessageTemplate string `yaml:"commit_msg_template,omitempty"`
|
||||||
Homepage string `yaml:",omitempty"`
|
Homepage string `yaml:",omitempty"`
|
||||||
|
@ -24,6 +24,10 @@ scoop:
|
|||||||
# Optionally a token can be provided, if it differs from the token provided to GoReleaser
|
# Optionally a token can be provided, if it differs from the token provided to GoReleaser
|
||||||
token: "{{ .Env.SCOOP_BUCKET_GITHUB_TOKEN }}"
|
token: "{{ .Env.SCOOP_BUCKET_GITHUB_TOKEN }}"
|
||||||
|
|
||||||
|
# Folder inside the repository to put the scoop.
|
||||||
|
# Default is the root folder.
|
||||||
|
folder: Scoops
|
||||||
|
|
||||||
# Git author used to commit to the repository.
|
# Git author used to commit to the repository.
|
||||||
# Defaults are shown.
|
# Defaults are shown.
|
||||||
commit_author:
|
commit_author:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user