1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-11 14:39:28 +02:00

feat: allow to always log signing output (#2731)

* feat: allow to always log signing output

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* fix: improve code a bit

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
This commit is contained in:
Carlos Alexandro Becker 2021-12-06 10:07:47 -03:00 committed by GitHub
parent f0c0ba5720
commit 7c2a93cfaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 3 deletions

View File

@ -22,7 +22,12 @@ const (
// NewWriter creates a new log writer. // NewWriter creates a new log writer.
func NewWriter(fields log.Fields, out Output) io.Writer { func NewWriter(fields log.Fields, out Output) io.Writer {
if isDebug() { return NewConditionalWriter(fields, out, false)
}
// NewConditionalWriter creates a new log writer that only writes when the given condition is met or debug is enabled.
func NewConditionalWriter(fields log.Fields, out Output, condition bool) io.Writer {
if condition || isDebug() {
return logWriter{ return logWriter{
ctx: newLogger(fields), ctx: newLogger(fields),
out: out, out: out,

View File

@ -185,8 +185,8 @@ func signone(ctx *context.Context, cfg config.Sign, art *artifact.Artifact) ([]*
cmd := exec.CommandContext(ctx, cfg.Cmd, args...) cmd := exec.CommandContext(ctx, cfg.Cmd, args...)
var b bytes.Buffer var b bytes.Buffer
w := gio.Safe(&b) w := gio.Safe(&b)
cmd.Stderr = io.MultiWriter(logext.NewWriter(fields, logext.Error), w) cmd.Stderr = io.MultiWriter(logext.NewConditionalWriter(fields, logext.Error, cfg.Output), w)
cmd.Stdout = io.MultiWriter(logext.NewWriter(fields, logext.Info), w) cmd.Stdout = io.MultiWriter(logext.NewConditionalWriter(fields, logext.Info, cfg.Output), w)
if stdin != nil { if stdin != nil {
cmd.Stdin = stdin cmd.Stdin = stdin
} }

View File

@ -631,6 +631,7 @@ type Sign struct {
StdinFile string `yaml:"stdin_file,omitempty"` StdinFile string `yaml:"stdin_file,omitempty"`
Env []string `yaml:"env,omitempty"` Env []string `yaml:"env,omitempty"`
Certificate string `yaml:"certificate,omitempty"` Certificate string `yaml:"certificate,omitempty"`
Output bool `yaml:"output,omitempty"`
} }
// SnapcraftAppMetadata for the binaries that will be in the snap package. // SnapcraftAppMetadata for the binaries that will be in the snap package.

View File

@ -61,6 +61,12 @@ docker_signs:
env: env:
- FOO=bar - FOO=bar
- HONK=honkhonk - HONK=honkhonk
# By default, the stdout and stderr of the signing cmd are discarded unless GoReleaser is running with `--debug` set.
# You can set this to true if you want them to be displayed regardless.
#
# Defaults to false
output: true
``` ```
### Available variable names ### Available variable names

View File

@ -97,6 +97,12 @@ signs:
env: env:
- FOO=bar - FOO=bar
- HONK=honkhonk - HONK=honkhonk
# By default, the stdout and stderr of the signing cmd are discarded unless GoReleaser is running with `--debug` set.
# You can set this to true if you want them to be displayed regardless.
#
# Defaults to false
output: true
``` ```
### Available variable names ### Available variable names