You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-15 01:34:21 +02:00
feat: write formula to dist
This commit is contained in:
committed by
Carlos Alexandro Becker
parent
26231995f5
commit
43c65c19c1
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
@ -111,14 +112,23 @@ func doRun(ctx *context.Context, client client.Client) error {
|
|||||||
if len(archives) > 1 {
|
if len(archives) > 1 {
|
||||||
return ErrTooManyDarwin64Builds
|
return ErrTooManyDarwin64Builds
|
||||||
}
|
}
|
||||||
var path = filepath.Join(ctx.Config.Brew.Folder, ctx.Config.ProjectName+".rb")
|
|
||||||
log.WithField("formula", path).
|
|
||||||
WithField("repo", ctx.Config.Brew.GitHub.String()).
|
|
||||||
Info("pushing")
|
|
||||||
content, err := buildFormula(ctx, client, archives[0])
|
content, err := buildFormula(ctx, client, archives[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var filename = ctx.Config.ProjectName + ".rb"
|
||||||
|
var path = filepath.Join(ctx.Config.Dist, filename)
|
||||||
|
log.WithField("formula", path).Info("writing")
|
||||||
|
if err := ioutil.WriteFile(path, content.Bytes(), 0644); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
path = filepath.Join(ctx.Config.Brew.Folder, filename)
|
||||||
|
log.WithField("formula", path).
|
||||||
|
WithField("repo", ctx.Config.Brew.GitHub.String()).
|
||||||
|
Info("pushing")
|
||||||
return client.CreateFile(ctx, content, path)
|
return client.CreateFile(ctx, content, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +145,8 @@ func TestRunPipe(t *testing.T) {
|
|||||||
_, err = os.Create(path)
|
_, err = os.Create(path)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
var distFile = filepath.Join(folder, "run-pipe.rb")
|
||||||
|
|
||||||
t.Run("default git url", func(tt *testing.T) {
|
t.Run("default git url", func(tt *testing.T) {
|
||||||
assert.NoError(tt, doRun(ctx, client))
|
assert.NoError(tt, doRun(ctx, client))
|
||||||
assert.True(tt, client.CreatedFile)
|
assert.True(tt, client.CreatedFile)
|
||||||
@ -155,6 +157,10 @@ func TestRunPipe(t *testing.T) {
|
|||||||
bts, err := ioutil.ReadFile(golden)
|
bts, err := ioutil.ReadFile(golden)
|
||||||
assert.NoError(tt, err)
|
assert.NoError(tt, err)
|
||||||
assert.Equal(tt, string(bts), client.Content)
|
assert.Equal(tt, string(bts), client.Content)
|
||||||
|
|
||||||
|
distBts, err := ioutil.ReadFile(distFile)
|
||||||
|
assert.NoError(tt, err)
|
||||||
|
assert.Equal(tt, string(bts), string(distBts))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("github enterprise url", func(tt *testing.T) {
|
t.Run("github enterprise url", func(tt *testing.T) {
|
||||||
@ -168,6 +174,10 @@ func TestRunPipe(t *testing.T) {
|
|||||||
bts, err := ioutil.ReadFile(golden)
|
bts, err := ioutil.ReadFile(golden)
|
||||||
assert.NoError(tt, err)
|
assert.NoError(tt, err)
|
||||||
assert.Equal(tt, string(bts), client.Content)
|
assert.Equal(tt, string(bts), client.Content)
|
||||||
|
|
||||||
|
distBts, err := ioutil.ReadFile(distFile)
|
||||||
|
assert.NoError(tt, err)
|
||||||
|
assert.Equal(tt, string(bts), string(distBts))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user