1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

feat: write formula to dist

This commit is contained in:
Carlos Alexandro Becker 2018-01-09 21:31:18 -02:00 committed by Carlos Alexandro Becker
parent 26231995f5
commit 43c65c19c1
2 changed files with 24 additions and 4 deletions
pipeline/brew

@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"path/filepath"
"strings"
"text/template"
@ -111,14 +112,23 @@ func doRun(ctx *context.Context, client client.Client) error {
if len(archives) > 1 {
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])
if err != nil {
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)
}

@ -145,6 +145,8 @@ func TestRunPipe(t *testing.T) {
_, err = os.Create(path)
assert.NoError(t, err)
var distFile = filepath.Join(folder, "run-pipe.rb")
t.Run("default git url", func(tt *testing.T) {
assert.NoError(tt, doRun(ctx, client))
assert.True(tt, client.CreatedFile)
@ -155,6 +157,10 @@ func TestRunPipe(t *testing.T) {
bts, err := ioutil.ReadFile(golden)
assert.NoError(tt, err)
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) {
@ -168,6 +174,10 @@ func TestRunPipe(t *testing.T) {
bts, err := ioutil.ReadFile(golden)
assert.NoError(tt, err)
assert.Equal(tt, string(bts), client.Content)
distBts, err := ioutil.ReadFile(distFile)
assert.NoError(tt, err)
assert.Equal(tt, string(bts), string(distBts))
})
}