mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-04 03:11:55 +02:00
Clean logging output
This commit is contained in:
parent
655e64b4bf
commit
6677571e8c
@ -17,7 +17,7 @@ type Pipe struct{}
|
|||||||
|
|
||||||
// Description of the pipe
|
// Description of the pipe
|
||||||
func (Pipe) Description() string {
|
func (Pipe) Description() string {
|
||||||
return "Creating archives..."
|
return "Creating archives"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the pipe
|
// Run the pipe
|
||||||
@ -41,7 +41,7 @@ type Archive interface {
|
|||||||
func create(name string, ctx *context.Context) error {
|
func create(name string, ctx *context.Context) error {
|
||||||
folder := filepath.Join("dist", name)
|
folder := filepath.Join("dist", name)
|
||||||
file, err := os.Create(folder + "." + ctx.Config.Archive.Format)
|
file, err := os.Create(folder + "." + ctx.Config.Archive.Format)
|
||||||
log.Println("Creating", file.Name(), "...")
|
log.Println("Creating", file.Name())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ import (
|
|||||||
// contain darwin and/or goarch doesn't contain amd64)
|
// contain darwin and/or goarch doesn't contain amd64)
|
||||||
var ErrNoDarwin64Build = errors.New("brew tap requires a darwin amd64 build")
|
var ErrNoDarwin64Build = errors.New("brew tap requires a darwin amd64 build")
|
||||||
|
|
||||||
const formulae = `class {{ .Name }} < Formula
|
const formula = `class {{ .Name }} < Formula
|
||||||
desc "{{ .Desc }}"
|
desc "{{ .Desc }}"
|
||||||
homepage "{{ .Homepage }}"
|
homepage "{{ .Homepage }}"
|
||||||
url "https://github.com/{{ .Repo }}/releases/download/{{ .Tag }}/{{ .File }}.{{ .Format }}"
|
url "https://github.com/{{ .Repo }}/releases/download/{{ .Tag }}/{{ .File }}.{{ .Format }}"
|
||||||
@ -63,7 +63,7 @@ type Pipe struct{}
|
|||||||
|
|
||||||
// Description of the pipe
|
// Description of the pipe
|
||||||
func (Pipe) Description() string {
|
func (Pipe) Description() string {
|
||||||
return "Creating homebrew formulae..."
|
return "Creating homebrew formula"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the pipe
|
// Run the pipe
|
||||||
@ -76,8 +76,8 @@ func (Pipe) Run(ctx *context.Context) error {
|
|||||||
ctx.Config.Brew.Folder, ctx.Config.Build.BinaryName+".rb",
|
ctx.Config.Brew.Folder, ctx.Config.Build.BinaryName+".rb",
|
||||||
)
|
)
|
||||||
|
|
||||||
log.Println("Updating", path, "on", ctx.Config.Brew.Repo, "...")
|
log.Println("Pushing", path, "to", ctx.Config.Brew.Repo)
|
||||||
out, err := buildFormulae(ctx, client)
|
out, err := buildFormula(ctx, client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -107,17 +107,17 @@ func (Pipe) Run(ctx *context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildFormulae(ctx *context.Context, client *github.Client) (bytes.Buffer, error) {
|
func buildFormula(ctx *context.Context, client *github.Client) (bytes.Buffer, error) {
|
||||||
data, err := dataFor(ctx, client)
|
data, err := dataFor(ctx, client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return bytes.Buffer{}, err
|
return bytes.Buffer{}, err
|
||||||
}
|
}
|
||||||
return doBuildFormulae(data)
|
return doBuildFormula(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func doBuildFormulae(data templateData) (bytes.Buffer, error) {
|
func doBuildFormula(data templateData) (bytes.Buffer, error) {
|
||||||
var out bytes.Buffer
|
var out bytes.Buffer
|
||||||
tmpl, err := template.New(data.BinaryName).Parse(formulae)
|
tmpl, err := template.New(data.BinaryName).Parse(formula)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return out, err
|
return out, err
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func TestFullFormulae(t *testing.T) {
|
|||||||
data := defaultTemplateData
|
data := defaultTemplateData
|
||||||
data.Caveats = "Here are some caveats"
|
data.Caveats = "Here are some caveats"
|
||||||
data.Dependencies = []string{"gtk", "git"}
|
data.Dependencies = []string{"gtk", "git"}
|
||||||
out, err := doBuildFormulae(data)
|
out, err := doBuildFormula(data)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
formulae := out.String()
|
formulae := out.String()
|
||||||
assertDefaultTemplateData(t, formulae)
|
assertDefaultTemplateData(t, formulae)
|
||||||
@ -57,7 +57,7 @@ func TestFullFormulae(t *testing.T) {
|
|||||||
|
|
||||||
func TestFormulaeNoCaveats(t *testing.T) {
|
func TestFormulaeNoCaveats(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
out, err := doBuildFormulae(defaultTemplateData)
|
out, err := doBuildFormula(defaultTemplateData)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
formulae := out.String()
|
formulae := out.String()
|
||||||
assertDefaultTemplateData(t, formulae)
|
assertDefaultTemplateData(t, formulae)
|
||||||
|
@ -16,7 +16,7 @@ type Pipe struct{}
|
|||||||
|
|
||||||
// Description of the pipe
|
// Description of the pipe
|
||||||
func (Pipe) Description() string {
|
func (Pipe) Description() string {
|
||||||
return "Building..."
|
return "Building binaries"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the pipe
|
// Run the pipe
|
||||||
@ -42,7 +42,7 @@ func (Pipe) Run(ctx *context.Context) error {
|
|||||||
func build(name, goos, goarch string, ctx *context.Context) error {
|
func build(name, goos, goarch string, ctx *context.Context) error {
|
||||||
ldflags := ctx.Config.Build.Ldflags + " -X main.version=" + ctx.Git.CurrentTag
|
ldflags := ctx.Config.Build.Ldflags + " -X main.version=" + ctx.Git.CurrentTag
|
||||||
output := "dist/" + name + "/" + ctx.Config.Build.BinaryName + extFor(goos)
|
output := "dist/" + name + "/" + ctx.Config.Build.BinaryName + extFor(goos)
|
||||||
log.Println("Building", output, "...")
|
log.Println("Building", output)
|
||||||
cmd := exec.Command(
|
cmd := exec.Command(
|
||||||
"go",
|
"go",
|
||||||
"build",
|
"build",
|
||||||
|
@ -15,7 +15,7 @@ type Pipe struct{}
|
|||||||
|
|
||||||
// Description of the pipe
|
// Description of the pipe
|
||||||
func (Pipe) Description() string {
|
func (Pipe) Description() string {
|
||||||
return "Setting defaults..."
|
return "Setting defaults"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the pipe
|
// Run the pipe
|
||||||
|
2
pipeline/env/env.go
vendored
2
pipeline/env/env.go
vendored
@ -15,7 +15,7 @@ type Pipe struct{}
|
|||||||
|
|
||||||
// Description of the pipe
|
// Description of the pipe
|
||||||
func (Pipe) Description() string {
|
func (Pipe) Description() string {
|
||||||
return "Loading data from environment variables..."
|
return "Loading environment variables"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the pipe
|
// Run the pipe
|
||||||
|
@ -7,7 +7,7 @@ type Pipe struct{}
|
|||||||
|
|
||||||
// Description of the pipe
|
// Description of the pipe
|
||||||
func (Pipe) Description() string {
|
func (Pipe) Description() string {
|
||||||
return "Gathering Git data..."
|
return "Getting Git info"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the pipe
|
// Run the pipe
|
||||||
|
@ -16,7 +16,7 @@ type Pipe struct{}
|
|||||||
|
|
||||||
// Description of the pipe
|
// Description of the pipe
|
||||||
func (Pipe) Description() string {
|
func (Pipe) Description() string {
|
||||||
return "Releasing to GitHub..."
|
return "Releasing to GitHub"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the pipe
|
// Run the pipe
|
||||||
@ -48,11 +48,11 @@ func getOrCreateRelease(client *github.Client, ctx *context.Context) (*github.Re
|
|||||||
}
|
}
|
||||||
r, _, err := client.Repositories.GetReleaseByTag(owner, repo, ctx.Git.CurrentTag)
|
r, _, err := client.Repositories.GetReleaseByTag(owner, repo, ctx.Git.CurrentTag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Creating release", ctx.Git.CurrentTag, "on", ctx.Config.Release.Repo, "...")
|
log.Println("Creating release", ctx.Git.CurrentTag, "on", ctx.Config.Release.Repo)
|
||||||
r, _, err = client.Repositories.CreateRelease(owner, repo, data)
|
r, _, err = client.Repositories.CreateRelease(owner, repo, data)
|
||||||
return r, err
|
return r, err
|
||||||
}
|
}
|
||||||
log.Println("Updating existing release", ctx.Git.CurrentTag, "on", ctx.Config.Release.Repo, "...")
|
log.Println("Updating existing release", ctx.Git.CurrentTag, "on", ctx.Config.Release.Repo)
|
||||||
r, _, err = client.Repositories.EditRelease(owner, repo, *r.ID, data)
|
r, _, err = client.Repositories.EditRelease(owner, repo, *r.ID, data)
|
||||||
return r, err
|
return r, err
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ func upload(client *github.Client, releaseID int, archive string, ctx *context.C
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer func() { _ = file.Close() }()
|
defer func() { _ = file.Close() }()
|
||||||
log.Println("Uploading", file.Name(), "...")
|
log.Println("Uploading", file.Name())
|
||||||
_, _, err = client.Repositories.UploadReleaseAsset(
|
_, _, err = client.Repositories.UploadReleaseAsset(
|
||||||
ctx.ReleaseRepo.Owner,
|
ctx.ReleaseRepo.Owner,
|
||||||
ctx.ReleaseRepo.Name,
|
ctx.ReleaseRepo.Name,
|
||||||
|
@ -11,7 +11,7 @@ type Pipe struct{}
|
|||||||
|
|
||||||
// Description of the pipe
|
// Description of the pipe
|
||||||
func (Pipe) Description() string {
|
func (Pipe) Description() string {
|
||||||
return "Filling repositories data..."
|
return "Setting repositories"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the pipe
|
// Run the pipe
|
||||||
|
@ -19,7 +19,7 @@ type Pipe struct {
|
|||||||
|
|
||||||
// Description of the pipe
|
// Description of the pipe
|
||||||
func (p *Pipe) Description() string {
|
func (p *Pipe) Description() string {
|
||||||
return "Using source from latest tag..."
|
return "Using source from latest tag"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run uses the latest tag as source.
|
// Run uses the latest tag as source.
|
||||||
@ -30,7 +30,7 @@ func (p *Pipe) Run(ctx *context.Context) error {
|
|||||||
dirty := err != nil
|
dirty := err != nil
|
||||||
|
|
||||||
if dirty {
|
if dirty {
|
||||||
log.Println("Stashing changes...")
|
log.Println("Stashing changes")
|
||||||
cmd = exec.Command("git", "stash", "--include-untracked", "--quiet")
|
cmd = exec.Command("git", "stash", "--include-untracked", "--quiet")
|
||||||
var stdout bytes.Buffer
|
var stdout bytes.Buffer
|
||||||
cmd.Stdout = &stdout
|
cmd.Stdout = &stdout
|
||||||
@ -48,7 +48,7 @@ func (p *Pipe) Run(ctx *context.Context) error {
|
|||||||
wrongBranch := err != nil
|
wrongBranch := err != nil
|
||||||
|
|
||||||
if wrongBranch {
|
if wrongBranch {
|
||||||
log.Println("Checking out tag...")
|
log.Println("Checking out tag")
|
||||||
cmd = exec.Command("git", "checkout", ctx.Git.CurrentTag)
|
cmd = exec.Command("git", "checkout", ctx.Git.CurrentTag)
|
||||||
var stdout bytes.Buffer
|
var stdout bytes.Buffer
|
||||||
cmd.Stdout = &stdout
|
cmd.Stdout = &stdout
|
||||||
@ -66,7 +66,7 @@ func (p *Pipe) Run(ctx *context.Context) error {
|
|||||||
// Clean switches back to the original branch and restores changes.
|
// Clean switches back to the original branch and restores changes.
|
||||||
func (p *Pipe) Clean(ctx *context.Context) {
|
func (p *Pipe) Clean(ctx *context.Context) {
|
||||||
if p.wrongBranch {
|
if p.wrongBranch {
|
||||||
log.Println("Checking out original branch...")
|
log.Println("Checking out original branch")
|
||||||
cmd := exec.Command("git", "checkout", "-")
|
cmd := exec.Command("git", "checkout", "-")
|
||||||
var stdout bytes.Buffer
|
var stdout bytes.Buffer
|
||||||
cmd.Stdout = &stdout
|
cmd.Stdout = &stdout
|
||||||
@ -77,7 +77,7 @@ func (p *Pipe) Clean(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if p.dirty {
|
if p.dirty {
|
||||||
log.Println("Popping stashed changes...")
|
log.Println("Popping stashed changes")
|
||||||
cmd := exec.Command("git", "stash", "pop")
|
cmd := exec.Command("git", "stash", "pop")
|
||||||
var stdout bytes.Buffer
|
var stdout bytes.Buffer
|
||||||
cmd.Stdout = &stdout
|
cmd.Stdout = &stdout
|
||||||
|
Loading…
Reference in New Issue
Block a user