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

fix: improve brew/krew/scoop/nix/winget paths inside dist (#4137)

mimic the structure to be created in the target repo, and put each of
them in its own folder.

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker 2023-06-24 23:38:09 -03:00 committed by GitHub
parent 58ede9badd
commit 76ce66c060
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 33 additions and 20 deletions

View File

@ -256,7 +256,11 @@ func doRun(ctx *context.Context, brew config.Homebrew, cl client.ReleaserURLTemp
}
filename := brew.Name + ".rb"
path := filepath.Join(ctx.Config.Dist, filename)
path := filepath.Join(ctx.Config.Dist, "homebrew", brew.Folder, filename)
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
return err
}
log.WithField("formula", path).Info("writing")
if err := os.WriteFile(path, []byte(content), 0o644); err != nil { //nolint: gosec
return fmt.Errorf("failed to write brew formula: %w", err)

View File

@ -377,7 +377,7 @@ func TestFullPipe(t *testing.T) {
require.NoError(t, err)
require.NoError(t, f.Close())
client := client.NewMock()
distFile := filepath.Join(folder, name+".rb")
distFile := filepath.Join(folder, "homebrew", name+".rb")
require.NoError(t, Pipe{}.Default(ctx))
@ -455,7 +455,7 @@ func TestRunPipeNameTemplate(t *testing.T) {
require.NoError(t, err)
require.NoError(t, f.Close())
client := client.NewMock()
distFile := filepath.Join(folder, "foo_is_bar.rb")
distFile := filepath.Join(folder, "homebrew", "foo_is_bar.rb")
require.NoError(t, runAll(ctx, client))
require.NoError(t, publishAll(ctx, client))
@ -553,7 +553,7 @@ func TestRunPipeMultipleBrewsWithSkip(t *testing.T) {
require.True(t, cli.CreatedFile)
for _, brew := range ctx.Config.Brews {
distFile := filepath.Join(folder, brew.Name+".rb")
distFile := filepath.Join(folder, "homebrew", brew.Name+".rb")
_, err := os.Stat(distFile)
require.NoError(t, err, "file should exist: "+distFile)
}
@ -668,7 +668,7 @@ func TestRunPipeForMultipleAmd64Versions(t *testing.T) {
}
client := client.NewMock()
distFile := filepath.Join(folder, name+".rb")
distFile := filepath.Join(folder, "homebrew", name+".rb")
require.NoError(t, runAll(ctx, client))
require.NoError(t, publishAll(ctx, client))
@ -787,7 +787,7 @@ func TestRunPipeForMultipleArmVersions(t *testing.T) {
}
client := client.NewMock()
distFile := filepath.Join(folder, name+".rb")
distFile := filepath.Join(folder, "homebrew", name+".rb")
require.NoError(t, runAll(ctx, client))
require.NoError(t, publishAll(ctx, client))
@ -1342,7 +1342,7 @@ func TestRunPipeUniversalBinary(t *testing.T) {
require.NoError(t, err)
require.NoError(t, f.Close())
client := client.NewMock()
distFile := filepath.Join(folder, "unibin.rb")
distFile := filepath.Join(folder, "homebrew", "unibin.rb")
require.NoError(t, runAll(ctx, client))
require.NoError(t, publishAll(ctx, client))
@ -1425,7 +1425,7 @@ func TestRunPipeUniversalBinaryNotReplacing(t *testing.T) {
require.NoError(t, err)
require.NoError(t, f.Close())
client := client.NewMock()
distFile := filepath.Join(folder, "unibin.rb")
distFile := filepath.Join(folder, "homebrew", "unibin.rb")
require.NoError(t, runAll(ctx, client))
require.NoError(t, publishAll(ctx, client))

View File

@ -136,7 +136,10 @@ func doRun(ctx *context.Context, krew config.Krew, cl client.ReleaserURLTemplate
}
filename := krew.Name + ".yaml"
yamlPath := filepath.Join(ctx.Config.Dist, filename)
yamlPath := filepath.Join(ctx.Config.Dist, "krew", filename)
if err := os.MkdirAll(filepath.Dir(yamlPath), 0o755); err != nil {
return err
}
log.WithField("manifest", yamlPath).Info("writing")
if err := os.WriteFile(yamlPath, []byte("# This file was generated by GoReleaser. DO NOT EDIT.\n"+content), 0o644); err != nil { //nolint: gosec
return fmt.Errorf("failed to write krew manifest: %w", err)

View File

@ -301,7 +301,7 @@ func TestFullPipe(t *testing.T) {
require.NoError(t, err)
require.NoError(t, f.Close())
client := client.NewMock()
distFile := filepath.Join(folder, name+".yaml")
distFile := filepath.Join(folder, "krew", name+".yaml")
require.NoError(t, Pipe{}.Default(ctx))
err = runAll(ctx, client)
@ -434,7 +434,7 @@ func TestRunPipeUniversalBinary(t *testing.T) {
require.NoError(t, err)
require.NoError(t, f.Close())
client := client.NewMock()
distFile := filepath.Join(folder, manifestName(t)+".yaml")
distFile := filepath.Join(folder, "krew", manifestName(t)+".yaml")
require.NoError(t, runAll(ctx, client))
require.NoError(t, publishAll(ctx, client))
@ -515,7 +515,7 @@ func TestRunPipeUniversalBinaryNotReplacing(t *testing.T) {
require.NoError(t, err)
require.NoError(t, f.Close())
client := client.NewMock()
distFile := filepath.Join(folder, manifestName(t)+".yaml")
distFile := filepath.Join(folder, "krew", manifestName(t)+".yaml")
require.NoError(t, Pipe{}.Default(ctx))
require.NoError(t, runAll(ctx, client))
@ -572,7 +572,7 @@ func TestRunPipeNameTemplate(t *testing.T) {
require.NoError(t, err)
require.NoError(t, f.Close())
client := client.NewMock()
distFile := filepath.Join(folder, t.Name()+".yaml")
distFile := filepath.Join(folder, "krew", t.Name()+".yaml")
require.NoError(t, Pipe{}.Default(ctx))
require.NoError(t, runAll(ctx, client))
@ -662,7 +662,7 @@ func TestRunPipeMultipleKrewWithSkip(t *testing.T) {
require.True(t, cli.CreatedFile)
for _, manifest := range ctx.Config.Krews {
distFile := filepath.Join(folder, manifest.Name+".yaml")
distFile := filepath.Join(folder, "krew", manifest.Name+".yaml")
_, err := os.Stat(distFile)
require.NoError(t, err, "file should exist: "+distFile)
}
@ -770,7 +770,7 @@ func TestRunPipeForMultipleArmVersions(t *testing.T) {
}
client := client.NewMock()
distFile := filepath.Join(folder, name+".yaml")
distFile := filepath.Join(folder, "krew", name+".yaml")
require.NoError(t, Pipe{}.Default(ctx))
require.NoError(t, runAll(ctx, client))

View File

@ -148,8 +148,11 @@ func (p Pipe) doRun(ctx *context.Context, nix config.Nix, cl client.ReleaserURLT
}
nix.SkipUpload = skipUpload
filename := nix.Name + ".nix"
path := filepath.Join(ctx.Config.Dist, filename)
path := filepath.Join(ctx.Config.Dist, "nix", nix.Path)
filename := filepath.Base(path)
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
return err
}
content, err := preparePkg(ctx, nix, cl, p.prefetcher)
if err != nil {

View File

@ -190,7 +190,10 @@ func doRun(ctx *context.Context, scoop config.Scoop, cl client.ReleaserURLTempla
}
filename := scoop.Name + ".json"
path := filepath.Join(ctx.Config.Dist, filename)
path := filepath.Join(ctx.Config.Dist, "scoop", scoop.Folder, filename)
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
return err
}
log.WithField("manifest", path).Info("writing")
if err := os.WriteFile(path, content.Bytes(), 0o644); err != nil {
return fmt.Errorf("failed to write scoop manifest: %w", err)

View File

@ -1057,7 +1057,7 @@ func TestRunPipeScoopWithSkipUpload(t *testing.T) {
require.NoError(t, runAll(ctx, cli))
require.EqualError(t, publishAll(ctx, cli), `scoop.skip_upload is true`)
distFile := filepath.Join(folder, ctx.Config.Scoop.Name+".json")
distFile := filepath.Join(folder, "scoop", ctx.Config.Scoop.Name+".json")
_, err = os.Stat(distFile)
require.NoError(t, err, "file should exist: "+distFile)
}

View File

@ -20,7 +20,7 @@ func createYAML(ctx *context.Context, winget config.Winget, in any, tp artifact.
}
filename := winget.Name + extFor(tp)
path := filepath.Join(ctx.Config.Dist, winget.Path, filename)
path := filepath.Join(ctx.Config.Dist, "winget", winget.Path, filename)
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
return err
}