1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-05 13:15:26 +02:00

Merge remote-tracking branch 'origin/master' into archive

This commit is contained in:
Carlos Alexandro Becker 2017-06-22 11:04:21 -03:00
commit 21571bef84
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
14 changed files with 33 additions and 28 deletions

2
Gopkg.lock generated
View File

@ -100,6 +100,6 @@
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "15a60b1efa147cc2507589fd45e4b767e118c6853c6ae2e2728a6ba01b818fe4" inputs-digest = "d6da23d2c5d62fbc0e9d6effeeea88169d4c5add4eb620087f17af4853a41cc4"
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1

View File

@ -45,7 +45,7 @@ func (ctx *Context) AddArtifact(file string) {
file = strings.TrimPrefix(file, ctx.Config.Dist) file = strings.TrimPrefix(file, ctx.Config.Dist)
file = strings.Replace(file, "/", "", -1) file = strings.Replace(file, "/", "", -1)
ctx.Artifacts = append(ctx.Artifacts, file) ctx.Artifacts = append(ctx.Artifacts, file)
log.WithField("artifact", file).Info("Registered") log.WithField("artifact", file).Info("registered")
} }
// New context // New context

View File

@ -56,7 +56,7 @@ func Release(flags Flags) error {
if !os.IsNotExist(statErr) || flags.IsSet("config") { if !os.IsNotExist(statErr) || flags.IsSet("config") {
return err return err
} }
log.WithField("file", file).Warn("Could not load") log.WithField("file", file).Warn("could not load config")
} }
var ctx = context.New(cfg) var ctx = context.New(cfg)
ctx.Validate = !flags.Bool("skip-validate") ctx.Validate = !flags.Bool("skip-validate")
@ -66,12 +66,12 @@ func Release(flags Flags) error {
if err != nil { if err != nil {
return err return err
} }
log.WithField("notes", notes).Info("Loaded custom release notes") log.WithField("notes", notes).Info("loaded custom release notes")
ctx.ReleaseNotes = string(bts) ctx.ReleaseNotes = string(bts)
} }
ctx.Snapshot = flags.Bool("snapshot") ctx.Snapshot = flags.Bool("snapshot")
if ctx.Snapshot { if ctx.Snapshot {
log.Info("Publishing disabled in snapshot mode") log.Info("publishing disabled in snapshot mode")
ctx.Publish = false ctx.Publish = false
} }
for _, pipe := range pipes { for _, pipe := range pipes {

View File

@ -98,7 +98,7 @@ func (c *githubClient) CreateRelease(ctx *context.Context, body string) (release
data, data,
) )
} }
log.Infof("Release updated: %v\n", release.GetHTMLURL()) log.WithField("url", release.GetHTMLURL()).Info("release updated")
return release.GetID(), err return release.GetID(), err
} }

View File

@ -53,7 +53,7 @@ func main() {
}, },
} }
app.Action = func(c *cli.Context) error { app.Action = func(c *cli.Context) error {
log.Infof("Running goreleaser %v", version) log.Infof("running goreleaser %v", version)
if err := goreleaserlib.Release(c); err != nil { if err := goreleaserlib.Release(c); err != nil {
return cli.NewExitError(err.Error(), 1) return cli.NewExitError(err.Error(), 1)
} }
@ -70,12 +70,13 @@ func main() {
return cli.NewExitError(err.Error(), 1) return cli.NewExitError(err.Error(), 1)
} }
log.Infof("%s created. Please edit accordingly to your needs.", filename) log.WithField("file", filename).
Info("config create, please edit accordingly to your needs")
return nil return nil
}, },
}, },
} }
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {
log.WithError(err).Fatal("Failed") log.WithError(err).Fatal("failed")
} }
} }

View File

@ -44,7 +44,7 @@ func create(ctx *context.Context, platform, name string) error {
if err != nil { if err != nil {
return err return err
} }
log.WithField("archive", file.Name()).Info("Creating") log.WithField("archive", file.Name()).Info("creating")
defer func() { _ = file.Close() }() defer func() { _ = file.Close() }()
var archive = archive.New(file) var archive = archive.New(file)
defer func() { _ = archive.Close() }() defer func() { _ = archive.Close() }()

View File

@ -95,19 +95,21 @@ func (Pipe) Run(ctx *context.Context) error {
func doRun(ctx *context.Context, client client.Client) error { func doRun(ctx *context.Context, client client.Client) error {
if !ctx.Publish { if !ctx.Publish {
log.Warn("Skipped because --skip-publish is set") log.Warn("skipped because --skip-publish is set")
return nil return nil
} }
if ctx.Config.Brew.GitHub.Name == "" { if ctx.Config.Brew.GitHub.Name == "" {
log.Warn("Skipped because brew section is not configured") log.Warn("skipped because brew section is not configured")
return nil return nil
} }
if ctx.Config.Release.Draft { if ctx.Config.Release.Draft {
log.Warn("Skipped because release is marked as draft") log.Warn("skipped because release is marked as draft")
return nil return nil
} }
path := filepath.Join(ctx.Config.Brew.Folder, ctx.Config.Build.Binary+".rb") path := filepath.Join(ctx.Config.Brew.Folder, ctx.Config.Build.Binary+".rb")
log.WithField("formula", path).WithField("repo", ctx.Config.Brew.GitHub.String()).Info("Pushing") log.WithField("formula", path).
WithField("repo", ctx.Config.Brew.GitHub.String()).
Info("pushing")
content, err := buildFormula(ctx, client) content, err := buildFormula(ctx, client)
if err != nil { if err != nil {
return err return err

View File

@ -56,7 +56,7 @@ func runHook(env []string, hook string) error {
if hook == "" { if hook == "" {
return nil return nil
} }
log.WithField("hook", hook).Info("Running hook") log.WithField("hook", hook).Info("running hook")
cmd := strings.Fields(hook) cmd := strings.Fields(hook)
return run(runtimeTarget, cmd, env) return run(runtimeTarget, cmd, env)
} }
@ -67,7 +67,7 @@ func build(ctx *context.Context, name string, target buildTarget) error {
name, name,
ctx.Config.Build.Binary+ext.For(target.goos), ctx.Config.Build.Binary+ext.For(target.goos),
) )
log.WithField("binary", output).Info("Building") log.WithField("binary", output).Info("building")
cmd := []string{"go", "build"} cmd := []string{"go", "build"}
if ctx.Config.Build.Flags != "" { if ctx.Config.Build.Flags != "" {
cmd = append(cmd, strings.Fields(ctx.Config.Build.Flags)...) cmd = append(cmd, strings.Fields(ctx.Config.Build.Flags)...)
@ -88,7 +88,7 @@ func run(target buildTarget, command, env []string) error {
log.WithField("target", target.PrettyString()). log.WithField("target", target.PrettyString()).
WithField("env", env). WithField("env", env).
WithField("args", cmd.Args). WithField("args", cmd.Args).
Debug("Running") Debug("running")
if out, err := cmd.CombinedOutput(); err != nil { if out, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("build failed: %s\n%v", target.PrettyString(), string(out)) return fmt.Errorf("build failed: %s\n%v", target.PrettyString(), string(out))
} }

View File

@ -26,11 +26,13 @@ func (t buildTarget) PrettyString() string {
func buildTargets(ctx *context.Context) (targets []buildTarget) { func buildTargets(ctx *context.Context) (targets []buildTarget) {
for _, target := range allBuildTargets(ctx) { for _, target := range allBuildTargets(ctx) {
if !valid(target) { if !valid(target) {
log.WithField("target", target.PrettyString()).Warn("Skipped invalid build") log.WithField("target", target.PrettyString()).
Warn("skipped invalid build")
continue continue
} }
if ignored(ctx, target) { if ignored(ctx, target) {
log.WithField("target", target.PrettyString()).Warn("Skipped ignored build") log.WithField("target", target.PrettyString()).
Warn("skipped ignored build")
continue continue
} }
targets = append(targets, target) targets = append(targets, target)

View File

@ -49,7 +49,7 @@ func (Pipe) Run(ctx *context.Context) (err error) {
} }
func checksums(ctx *context.Context, file *os.File, name string) error { func checksums(ctx *context.Context, file *os.File, name string) error {
log.WithField("file", name).Info("Checksumming") log.WithField("file", name).Info("checksumming")
var artifact = filepath.Join(ctx.Config.Dist, name) var artifact = filepath.Join(ctx.Config.Dist, name)
sha, err := checksum.SHA256(artifact) sha, err := checksum.SHA256(artifact)
if err != nil { if err != nil {

4
pipeline/env/env.go vendored
View File

@ -25,11 +25,11 @@ func (Pipe) Description() string {
func (Pipe) Run(ctx *context.Context) (err error) { func (Pipe) Run(ctx *context.Context) (err error) {
ctx.Token = os.Getenv("GITHUB_TOKEN") ctx.Token = os.Getenv("GITHUB_TOKEN")
if !ctx.Publish { if !ctx.Publish {
log.Warn("GITHUB_TOKEN not validated because publishing has been disabled") log.Warn("github token not validated because publishing has been disabled")
return nil return nil
} }
if !ctx.Validate { if !ctx.Validate {
log.Warn("Skipped validations because --skip-validate is set") log.Warn("skipped validations because --skip-validate is set")
return nil return nil
} }
if ctx.Token == "" { if ctx.Token == "" {

View File

@ -30,7 +30,7 @@ func (Pipe) Description() string {
// Run the pipe // Run the pipe
func (Pipe) Run(ctx *context.Context) error { func (Pipe) Run(ctx *context.Context) error {
if len(ctx.Config.FPM.Formats) == 0 { if len(ctx.Config.FPM.Formats) == 0 {
log.Info("No output formats configured, skipping") log.Info("no output formats configured, skipping")
return nil return nil
} }
_, err := exec.LookPath("fpm") _, err := exec.LookPath("fpm")

View File

@ -73,7 +73,7 @@ func (Pipe) Run(ctx *context.Context) (err error) {
return return
} }
if !ctx.Validate { if !ctx.Validate {
log.Warn("Skipped validations because --skip-validate is set") log.Warn("skipped validations because --skip-validate is set")
return nil return nil
} }
return validate(ctx, commit, tag) return validate(ctx, commit, tag)
@ -169,7 +169,7 @@ func gitLog(refs ...string) (string, error) {
func getInfo() (tag, commit string, err error) { func getInfo() (tag, commit string, err error) {
tag, err = cleanGit("describe", "--tags", "--abbrev=0") tag, err = cleanGit("describe", "--tags", "--abbrev=0")
if err != nil { if err != nil {
log.WithError(err).Info("Failed to retrieve current tag") log.WithError(err).Info("failed to retrieve current tag")
} }
commit, err = cleanGit("show", "--format='%H'", "HEAD") commit, err = cleanGit("show", "--format='%H'", "HEAD")
return return

View File

@ -27,12 +27,12 @@ func (Pipe) Run(ctx *context.Context) error {
func doRun(ctx *context.Context, client client.Client) error { func doRun(ctx *context.Context, client client.Client) error {
if !ctx.Publish { if !ctx.Publish {
log.Warn("Skipped because --skip-publish is set") log.Warn("skipped because --skip-publish is set")
return nil return nil
} }
log.WithField("tag", ctx.Git.CurrentTag). log.WithField("tag", ctx.Git.CurrentTag).
WithField("repo", ctx.Config.Release.GitHub.String()). WithField("repo", ctx.Config.Release.GitHub.String()).
Info("Creating or updating release") Info("creating or updating release")
body, err := describeBody(ctx) body, err := describeBody(ctx)
if err != nil { if err != nil {
return err return err
@ -58,6 +58,6 @@ func upload(ctx *context.Context, client client.Client, releaseID int, artifact
return err return err
} }
defer func() { _ = file.Close() }() defer func() { _ = file.Close() }()
log.WithField("file", file).Info("Uploading") log.WithField("file", file.Name()).Info("uploading")
return client.Upload(ctx, releaseID, artifact, file) return client.Upload(ctx, releaseID, artifact, file)
} }