mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-04-13 11:50:34 +02:00
apex log
This commit is contained in:
parent
1304bbc01f
commit
b8ff8e9b12
@ -8,10 +8,10 @@ package context
|
||||
|
||||
import (
|
||||
ctx "context"
|
||||
"log"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
)
|
||||
|
||||
@ -45,7 +45,7 @@ func (ctx *Context) AddArtifact(file string) {
|
||||
file = strings.TrimPrefix(file, ctx.Config.Dist)
|
||||
file = strings.Replace(file, "/", "", -1)
|
||||
ctx.Artifacts = append(ctx.Artifacts, file)
|
||||
log.Println("Registered artifact", file)
|
||||
log.WithField("artifact", file).Info("Registered")
|
||||
}
|
||||
|
||||
// New context
|
||||
|
@ -3,10 +3,9 @@ package context
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
func TestMultipleArtifactAdds(t *testing.T) {
|
||||
|
@ -1,14 +1,11 @@
|
||||
package goreleaserlib
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
yaml "gopkg.in/yaml.v1"
|
||||
|
||||
"fmt"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"github.com/goreleaser/goreleaser/pipeline"
|
||||
@ -21,6 +18,7 @@ import (
|
||||
"github.com/goreleaser/goreleaser/pipeline/fpm"
|
||||
"github.com/goreleaser/goreleaser/pipeline/git"
|
||||
"github.com/goreleaser/goreleaser/pipeline/release"
|
||||
yaml "gopkg.in/yaml.v1"
|
||||
)
|
||||
|
||||
var pipes = []pipeline.Pipe{
|
||||
@ -35,10 +33,6 @@ var pipes = []pipeline.Pipe{
|
||||
brew.Pipe{}, // push to brew tap
|
||||
}
|
||||
|
||||
func init() {
|
||||
log.SetFlags(0)
|
||||
}
|
||||
|
||||
// Flags interface represents an extractor of cli flags
|
||||
type Flags interface {
|
||||
IsSet(s string) bool
|
||||
@ -58,7 +52,7 @@ func Release(flags Flags) error {
|
||||
if !os.IsNotExist(statErr) || flags.IsSet("config") {
|
||||
return err
|
||||
}
|
||||
log.Printf("WARNING: Could not load %v\n", file)
|
||||
log.WithField("file", file).Warn("Could not load")
|
||||
}
|
||||
var ctx = context.New(cfg)
|
||||
ctx.Validate = !flags.Bool("skip-validate")
|
||||
@ -68,23 +62,21 @@ func Release(flags Flags) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Println("Loaded custom release notes from", notes)
|
||||
log.WithField("notes", notes).Info("Loaded custom release notes")
|
||||
ctx.ReleaseNotes = string(bts)
|
||||
}
|
||||
ctx.Snapshot = flags.Bool("snapshot")
|
||||
if ctx.Snapshot {
|
||||
log.Println("Publishing disabled in snapshot mode")
|
||||
log.Info("Publishing disabled in snapshot mode")
|
||||
ctx.Publish = false
|
||||
}
|
||||
for _, pipe := range pipes {
|
||||
log.Println(pipe.Description())
|
||||
log.SetPrefix(" -> ")
|
||||
log.Infof(pipe.Description())
|
||||
if err := pipe.Run(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
log.SetPrefix("")
|
||||
}
|
||||
log.Println("Done!")
|
||||
log.Info("Done!")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -2,16 +2,14 @@ package goreleaserlib
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
yaml "gopkg.in/yaml.v1"
|
||||
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
"github.com/stretchr/testify/assert"
|
||||
yaml "gopkg.in/yaml.v1"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -146,7 +144,6 @@ func setup(t *testing.T) (current string, back func()) {
|
||||
var assert = assert.New(t)
|
||||
folder, err := ioutil.TempDir("", "goreleaser")
|
||||
assert.NoError(err)
|
||||
log.Println("Folder:", folder)
|
||||
previous, err := os.Getwd()
|
||||
assert.NoError(err)
|
||||
assert.NoError(os.Chdir(folder))
|
||||
|
@ -2,9 +2,9 @@ package client
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/google/go-github/github"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"golang.org/x/oauth2"
|
||||
@ -98,7 +98,7 @@ func (c *githubClient) CreateRelease(ctx *context.Context, body string) (release
|
||||
data,
|
||||
)
|
||||
}
|
||||
log.Printf("Release updated: %v\n", release.GetHTMLURL())
|
||||
log.Infof("Release updated: %v\n", release.GetHTMLURL())
|
||||
return release.GetID(), err
|
||||
}
|
||||
|
||||
|
13
main.go
13
main.go
@ -2,9 +2,10 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/apex/log"
|
||||
lcli "github.com/apex/log/handlers/cli"
|
||||
"github.com/goreleaser/goreleaser/goreleaserlib"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
@ -15,6 +16,10 @@ var (
|
||||
date = "unknown"
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.SetHandler(lcli.New(os.Stdout))
|
||||
}
|
||||
|
||||
func main() {
|
||||
var app = cli.NewApp()
|
||||
app.Name = "goreleaser"
|
||||
@ -44,7 +49,7 @@ func main() {
|
||||
},
|
||||
}
|
||||
app.Action = func(c *cli.Context) error {
|
||||
log.Printf("Running goreleaser %v\n", version)
|
||||
log.Infof("Running goreleaser %v", version)
|
||||
if err := goreleaserlib.Release(c); err != nil {
|
||||
return cli.NewExitError(err.Error(), 1)
|
||||
}
|
||||
@ -61,12 +66,12 @@ func main() {
|
||||
return cli.NewExitError(err.Error(), 1)
|
||||
}
|
||||
|
||||
log.Printf("%s created. Please edit accordingly to your needs.", filename)
|
||||
log.Infof("%s created. Please edit accordingly to your needs.", filename)
|
||||
return nil
|
||||
},
|
||||
},
|
||||
}
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
log.Fatalln(err)
|
||||
log.WithError(err).Fatal("Failed")
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,11 @@
|
||||
package archive
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/goreleaser/archive"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"github.com/goreleaser/goreleaser/internal/ext"
|
||||
@ -44,7 +44,7 @@ func create(ctx *context.Context, platform, name string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Println("Creating", file.Name())
|
||||
log.WithField("archive", file.Name()).Info("Creating")
|
||||
defer func() { _ = file.Close() }()
|
||||
var archive = archive.New(file)
|
||||
defer func() { _ = archive.Close() }()
|
||||
|
@ -5,11 +5,11 @@ package brew
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/goreleaser/goreleaser/checksum"
|
||||
"github.com/goreleaser/goreleaser/config"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
@ -95,19 +95,19 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
|
||||
func doRun(ctx *context.Context, client client.Client) error {
|
||||
if !ctx.Publish {
|
||||
log.Println("Skipped because --skip-publish is set")
|
||||
log.Info("Skipped because --skip-publish is set")
|
||||
return nil
|
||||
}
|
||||
if ctx.Config.Brew.GitHub.Name == "" {
|
||||
log.Println("Skipped because brew section is not configured")
|
||||
log.Info("Skipped because brew section is not configured")
|
||||
return nil
|
||||
}
|
||||
if ctx.Config.Release.Draft {
|
||||
log.Println("Skipped because release is marked as draft")
|
||||
log.Info("Skipped because release is marked as draft")
|
||||
return nil
|
||||
}
|
||||
path := filepath.Join(ctx.Config.Brew.Folder, ctx.Config.Build.Binary+".rb")
|
||||
log.Println("Pushing", path, "to", ctx.Config.Brew.GitHub.String())
|
||||
log.WithField("formula", path).WithField("repo", ctx.Config.Brew.GitHub.String()).Info("Pushing")
|
||||
content, err := buildFormula(ctx, client)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -4,12 +4,12 @@ package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"github.com/goreleaser/goreleaser/internal/ext"
|
||||
"golang.org/x/sync/errgroup"
|
||||
@ -56,7 +56,7 @@ func runHook(env []string, hook string) error {
|
||||
if hook == "" {
|
||||
return nil
|
||||
}
|
||||
log.Println("Running hook", hook)
|
||||
log.WithField("hook", hook).Info("Running hook")
|
||||
cmd := strings.Fields(hook)
|
||||
return run(runtimeTarget, cmd, env)
|
||||
}
|
||||
@ -67,7 +67,7 @@ func build(ctx *context.Context, name string, target buildTarget) error {
|
||||
name,
|
||||
ctx.Config.Build.Binary+ext.For(target.goos),
|
||||
)
|
||||
log.Println("Building", output)
|
||||
log.WithField("binary", output).Info("Building")
|
||||
cmd := []string{"go", "build"}
|
||||
if ctx.Config.Build.Flags != "" {
|
||||
cmd = append(cmd, strings.Fields(ctx.Config.Build.Flags)...)
|
||||
|
@ -2,9 +2,9 @@ package build
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"runtime"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
)
|
||||
|
||||
@ -26,11 +26,11 @@ func (t buildTarget) PrettyString() string {
|
||||
func buildTargets(ctx *context.Context) (targets []buildTarget) {
|
||||
for _, target := range allBuildTargets(ctx) {
|
||||
if !valid(target) {
|
||||
log.Println("Skipped invalid build target:", target.PrettyString())
|
||||
log.WithField("target", target.PrettyString()).Info("Skipped invalid build")
|
||||
continue
|
||||
}
|
||||
if ignored(ctx, target) {
|
||||
log.Println("Skipped ignored build target:", target.PrettyString())
|
||||
log.WithField("target", target.PrettyString()).Info("Skipped ignored build")
|
||||
continue
|
||||
}
|
||||
targets = append(targets, target)
|
||||
|
@ -4,10 +4,10 @@ package checksums
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/goreleaser/goreleaser/checksum"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"golang.org/x/sync/errgroup"
|
||||
@ -49,7 +49,7 @@ func (Pipe) Run(ctx *context.Context) (err error) {
|
||||
}
|
||||
|
||||
func checksums(ctx *context.Context, file *os.File, name string) error {
|
||||
log.Println("Checksumming", name)
|
||||
log.WithField("file", name).Info("Checksumming")
|
||||
var artifact = filepath.Join(ctx.Config.Dist, name)
|
||||
sha, err := checksum.SHA256(artifact)
|
||||
if err != nil {
|
||||
|
6
pipeline/env/env.go
vendored
6
pipeline/env/env.go
vendored
@ -4,9 +4,9 @@ package env
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
)
|
||||
|
||||
@ -25,11 +25,11 @@ func (Pipe) Description() string {
|
||||
func (Pipe) Run(ctx *context.Context) (err error) {
|
||||
ctx.Token = os.Getenv("GITHUB_TOKEN")
|
||||
if !ctx.Publish {
|
||||
log.Println("GITHUB_TOKEN not validated because publishing has been disabled")
|
||||
log.Warn("GITHUB_TOKEN not validated because publishing has been disabled")
|
||||
return nil
|
||||
}
|
||||
if !ctx.Validate {
|
||||
log.Println("Skipped validations because --skip-validate is set")
|
||||
log.Warn("Skipped validations because --skip-validate is set")
|
||||
return nil
|
||||
}
|
||||
if ctx.Token == "" {
|
||||
|
@ -3,10 +3,10 @@ package fpm
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"log"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
@ -30,7 +30,7 @@ func (Pipe) Description() string {
|
||||
// Run the pipe
|
||||
func (Pipe) Run(ctx *context.Context) error {
|
||||
if len(ctx.Config.FPM.Formats) == 0 {
|
||||
log.Println("No output formats configured, skipping")
|
||||
log.Info("No output formats configured, skipping")
|
||||
return nil
|
||||
}
|
||||
_, err := exec.LookPath("fpm")
|
||||
@ -59,7 +59,7 @@ func create(ctx *context.Context, format, archive, arch string) error {
|
||||
var path = filepath.Join(ctx.Config.Dist, archive)
|
||||
var file = path + "." + format
|
||||
var name = ctx.Config.Build.Binary
|
||||
log.Println("Creating", file)
|
||||
log.WithField("file", file).Info("Creating")
|
||||
|
||||
var options = []string{
|
||||
"--input-type", "dir",
|
||||
|
@ -5,13 +5,12 @@ package git
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"text/template"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
)
|
||||
|
||||
@ -74,7 +73,7 @@ func (Pipe) Run(ctx *context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
if !ctx.Validate {
|
||||
log.Println("Skipped validations because --skip-validate is set")
|
||||
log.Warn("Skipped validations because --skip-validate is set")
|
||||
return nil
|
||||
}
|
||||
return validate(ctx, commit, tag)
|
||||
@ -170,7 +169,7 @@ func gitLog(refs ...string) (string, error) {
|
||||
func getInfo() (tag, commit string, err error) {
|
||||
tag, err = cleanGit("describe", "--tags", "--abbrev=0")
|
||||
if err != nil {
|
||||
log.Printf("Failed to retrieve current tag: %s", err.Error())
|
||||
log.WithError(err).Info("Failed to retrieve current tag")
|
||||
}
|
||||
commit, err = cleanGit("show", "--format='%H'", "HEAD")
|
||||
return
|
||||
|
@ -3,10 +3,10 @@
|
||||
package release
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"github.com/goreleaser/goreleaser/internal/client"
|
||||
"golang.org/x/sync/errgroup"
|
||||
@ -27,10 +27,12 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
|
||||
func doRun(ctx *context.Context, client client.Client) error {
|
||||
if !ctx.Publish {
|
||||
log.Println("Skipped because --skip-publish is set")
|
||||
log.Info("Skipped because --skip-publish is set")
|
||||
return nil
|
||||
}
|
||||
log.Println("Creating or updating release", ctx.Git.CurrentTag, "on", ctx.Config.Release.GitHub.String())
|
||||
log.WithField("tag", ctx.Git.CurrentTag).
|
||||
WithField("repo", ctx.Config.Release.GitHub.String()).
|
||||
Info("Creating or updating release")
|
||||
body, err := describeBody(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -56,6 +58,6 @@ func upload(ctx *context.Context, client client.Client, releaseID int, artifact
|
||||
return err
|
||||
}
|
||||
defer func() { _ = file.Close() }()
|
||||
log.Println("Uploading", file.Name())
|
||||
log.WithField("file", file).Info("Uploading")
|
||||
return client.Upload(ctx, releaseID, artifact, file)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user